({"code":0,"msg":"success","body":{"personal":0,"enterprise":0,"enterprise":0,"unread":0}})
这种格式的json数据怎么解析?我用eval解析不出来
整个是一个JSON数组,用JSONArray接受数据,在里面首先是两个JSON数据,用JSONObject解析,然后里面还有一个JSON数组,数组里面还有JSON数据,所以先调用JSONArray,在用JSONObject
试着把“(” 与 “)” 去掉,
你的JSON解析没有通过。
然后用
var jsonstr = '{"code":0,"msg":"success","body":{"personal":0,"enterprise":0,"enterprise":0,"unread":0}}';
var obj = JSON.parse(jsonstr);
console.log(obj.code)