python json解析 转义_Python解析带有转义双引号的JSON

请考虑以下有效的json:

{"a": 1, "b": "{\"c\":2}"}

当我试图解析Python的json模块时抛出它—看起来\"正在抛出它:json.loads('{"a": 1, "b": "{\"c\":2}"}')

Traceback (most recent call last):

File "", line 1, in

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads

return _default_decoder.decode(s)

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 381, in raw_decode

obj, end = self.scan_once(s, idx)

ValueError: Expecting , delimiter: line 1 column 15 (char 14)

在Python中有没有任何方法可以解析它,要么使用json模块,要么使用ujson之类的其他模块?在

你可能感兴趣的:(python,json解析,转义)