RT,服务器返回的json格式的数据有一些地方与python不一样,如"a":true
, 用python自带的json模块进行解析总是出错,请问python一般怎么解析这些数据
黄舟2017-04-17 13:03:54
Use spidermonkey or v8’s python binding to do JSON.stringify on the incoming data as a js object.
You can also go through node.js through subprocess.
PHP中文网2017-04-17 13:03:54
You can use JSON.stringfy to pre-process the data on the front end as described by yj.lee, or when using python to parse, pass a preprocessing function (json.decoder) like the cls parameter of json.loads() to Data preprocessing.
天蓬老师2017-04-17 13:03:54
First of all, you need to make sure your json format is correct. Generally, python’s json will not go wrong. After all, we are not Inspur front-end people. The main cause of the problem may be that the json format is incorrect.
It is recommended to post it in json format for a look.
If it is the above "a":true
you need to do this
>>> import json
>>> json.loads(json.dumps('"a":true'))
u'"a":true'