JSON

这样的JSON怎么解析成二维数组并输出 JavaScript DHTML 脚本技术

字号+ 作者:H5之家 来源:H5之家 2018-01-23 11:25 我要评论( )

这样的JSON怎么解析成二维数组并输出


  • <div id="all"></div>
  • <script>
  • var json=[{"cid":"25","cno":"B15","cname":"\u5bab\u7206\u9e21\u4e01\u76d6\u6d47

  • \u996d","cprice":"7","shangjia":"\u805a\u9999\u56ed\u9910\u9986","open":"1"},

  • {"cid":"26","cno":"B16","cname":"\u6728\u8033\u8089\u7247\u76d6\u6d47

  • \u996d","cprice":"7","shangjia":"\u805a\u9999\u56ed\u9910\u9986","open":"1"},

  • {"cid":"27","cno":"B17","cname":"\u9999\u83c7\u8089\u7247\u76d6\u6d47

  • \u996d","cprice":"7","shangjia":"\u805a\u9999\u56ed\u9910\u9986","open":"1"},

  • {"cid":"28","cno":"B18","cname":"\u9178\u8fa3\u91cc\u810a\u76d6\u6d47

  • \u996d","cprice":"8","shangjia":"\u805a\u9999\u56ed\u9910\u9986","open":"1"},

  • {"cid":"29","cno":"B19","cname":"\u7cd6\u918b\u91cc\u810a\u76d6\u6d47

  • \u996d","cprice":"8","shangjia":"\u805a\u9999\u56ed\u9910\u9986","open":"1"},

  • {"cid":"30","cno":"C01","cname":"\u4e94\u8c37\u8c46\u6d46","cprice":"1","shangjia":"\u6e05

  • \u96c5\u5c45\u9910\u5385","open":"1"},{"cid":"31","cno":"C02","cname":"\u8425\u517b\u5957

  • \u9910\uff08\u9e21\u817f\uff0c\u4e00\u8364\uff0c\u4e8c\u7d20

  • \uff09","cprice":"6","shangjia":"\u6e05\u96c5\u5c45\u9910\u5385","open":"1"},

  • {"cid":"32","cno":"C03","cname":"\u8089\u7092

  • \u9ebb\u4ec0","cprice":"4.5","shangjia":"\u6e05\u96c5\u5c45\u9910\u5385","open":"1"},

  • {"cid":"33","cno":"C04","cname":"\u86cb\u7092

  • \u9ebb\u4ec0","cprice":"4.5","shangjia":"\u6e05\u96c5\u5c45\u9910\u5385","open":"1"},

  • {"cid":"34","cno":"C05","cname":"\u8089\u7092\u9762","cprice":"4.5","shangjia":"\u6e05

  • \u96c5\u5c45\u9910\u5385","open":"1"},{"cid":"35","cno":"C06","cname":"\u86cb\u7092

  • \u9762","cprice":"4.5","shangjia":"\u6e05\u96c5\u5c45\u9910\u5385","open":"1"},

  • {"cid":"36","cno":"C07","cname":"\u86cb\u7092\u996d","cprice":"4.5","shangjia":"\u6e05

  • \u96c5\u5c45\u9910\u5385","open":"1"}];
  • for (var i=0;i<json.length;i++)
  • {
  • var index=0;
  • index=i;
  • var io="";
  • io=io+json[index].cid+json[index].cname+json[index].cprice+json[index].shangjia+json

  • [index].open;
  • index++;
  • document.write(json[i].cid+"<br />"+json[i].cname+"  "+json[i].cprice+json[i].shangjia+json

  • [i].open);
  • }
  • alert(typeof(json[2].cid));
  • document.getElementById('all').innerHTML=io;
  • </script>

     

  • 1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

    相关文章
    网友点评