Python解析服务器返回的json格式数据
巴扎黑
巴扎黑 2017-04-17 13:01:54
0
3
676

RT,服务器返回的json格式的数据有一些地方与python不一样,如"a":true, 用python自带的json模块进行解析总是出错,请问python一般怎么解析这些数据

巴扎黑
巴扎黑

reply all(3)
黄舟

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.

洪涛

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.

Peter_Zhu

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'
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!