如何解析js读出的json数据 {"code":"1","msg":"\u6210\u529f"#

{"code":"1","msg":"\u6210\u529f","result":[{"pid":"1","pname":"E\u5149\u51b0\u70b9\u8... {"code":"1","msg":"\u6210\u529f","result":[{"pid":"1","pname":"E\u5149\u51b0\u70b9\u8131\u6bdb","price":"634","p_wmoney":"443","sum_commnet":"123","p_jinfo":"\u4ec5\u552e12.8\u5143\uff01\u4ef7\u503c634\u5143\u7684E\u5149\u51b0\u70b9\u8131\u6bdb\/\u70b9\u7a74\u51cf\u80a5\u5851\u5f622\u90091\u5957\u9910\uff0c\u7537\u5973\u4e0d\u9650\uff0c\u63d0\u4f9b\u514d\u8d39WiFi\u3002\u8ba9\u7f8e\u4e3d\u7efd\u653e\uff0c\u8ba9\u9752\u6625\u6c38\u9a7b\uff01","p_xinfo":"\r\n E\u5149\u51b0\u70b9\u8131\u6bdb\/\u70b9\u7a74\u51cf\u80a5\u5851\u5f622\u90091\u5957\u9910\u670d\u52a1\u6d41\u7a0b\/\u65f6\u957f\uff1a\u814b\u4e0b\uff0c\u5c0f\u81c2\u5c0f\u817f\uff0c\u624b\u80cc\uff0c\u5507\u6bdb\uff0c\u53d1\u9645\u7ebf\uff0c\u8110\u5468\u7b49\u5341\u4e94\u4e2a\u90e8\u4f4d\u4efb\u9009\u5176\u4e00\uff0c30\u5206\u949f\uff1b\r\n \u8131\u6bdb\u7684\u51e0\u5927\u6b65\u9aa4\r\n 展开
 我来答
游侠的我我我我
推荐于2019-09-08 · TA获得超过2314个赞
知道小有建树答主
回答量:5
采纳率:0%
帮助的人:786
展开全部
  • unescape('\u4ec5\u552e12.8\u5143\uff01\u4ef7\u503c634\u5143\u7684E\u5149\u51b0\u70b9\u8131\u6bdb\/\u70b9\u7a74\u51cf\u80a5\u5851\u5f622\u90091\u5957\u9910\uff0c\u7537\u5973\u4e0d\u9650\uff0c\u63d0\u4f9b\u514d\u8d39WiFi\u3002\u8ba9\u7f8e\u4e3d\u7efd\u653e\uff0c\u8ba9\u9752\u6625\u6c38\u9a7b\uff01');

  • 以下是几种js读出的json数据的方式:

    var json = {  contry:{ area:{ man:"12万",  women:"10万" } } };

  • 方式一:使用eval解析  var obj = eval(json);  alert(obj.constructor);alert(obj.contry.area.women);   //

  • 方式二:使用Funtion函数 

    var strJSON = "{name:'json name'}";//得到JSON  var obj = new Function("return" + strJSON)();//转换后的JSON对象     alert(obj.name);//json name      alert(obj.constructor);    

  • 复杂一点的json数组数据的解析 var value1 = [{"c01":"1","c02":"2","c03":"3","c04":"4","c05":"5","c06":"6","c07":"7","c08":"8","c09":"9"}, {"c01":"2","c02":"4","c03":"5","c04":"2","c05":"8","c06":"11","c07":"21","c08":"1","c09":"12"}, {"c01":"5","c02":"1","c03":"4","c04":"11","c05":"9","c06":"8","c07":"1","c08":"8","c09":"2"}];   var obj1 = eval(value1);  alert(obj1[0].c01);  /

  • 复杂一点的json的另一种形式

    var value2 = {"list":[ {"password":"1230","username":"coolcooldool"}, {"password":"thisis2","username":"okokok"}], "array":[{"password":"1230","username":"coolcooldool"},{"password":"thisis2","username":"okokok"}]};   var obj2 = eval(value2);  alert(obj2.list[0].password);

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式