为了账号安全,请及时绑定邮箱和手机立即绑定

json 数组 js 获取值!

json 数组 js 获取值!

函数式编程 2019-03-11 21:14:31
{"rows":5,"result":[[{"item_id":"60","item_no":"0101010001","item_huo":"00001","item_name":"\u6563\u53f6\u751f\u83dc","item_price":"4.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"SYSC","stock_id":"87","stock_num":"0","stock_date":"2014-06-05 16:40:43","stock_weight":"0.000"}],[{"item_id":"61","item_no":"0101010003","item_huo":"00003","item_name":"\u6cb9\u9ea6\u83dc","item_price":"4.360","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"YMC","stock_id":"88","stock_num":"0","stock_date":"2014-06-05 16:51:41","stock_weight":"0.000"}],[{"item_id":"62","item_no":"0101010005","item_huo":"00005","item_name":"\u833c\u84bf","item_price":"7.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"TH","stock_id":"89","stock_num":"0","stock_date":"2014-06-05 16:51:45","stock_weight":"0.000"}],[{"item_id":"63","item_no":"0101010006","item_huo":"00006","item_name":"\u82a6\u84bf","item_price":"5.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"LH","stock_id":"90","stock_num":"0","stock_date":"2014-06-05 16:51:46","stock_weight":"0.000"}],[{"item_id":"64","item_no":"0101010008","item_huo":"00008","item_name":"\u5c0f\u83e0\u83dc","item_price":"5.960","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"XBC","stock_id":"91","stock_num":"0","stock_date":"2014-06-05 16:51:47","stock_weight":"0.000"}]]}JSON 怎么获取 result 的值?
查看完整描述

2 回答

?
森林海

TA贡献2011条经验 获得超2个赞

<script>

    var str = {"rows":5,"result":[[{"item_id":"60","item_no":"0101010001","item_huo":"00001","item_name":"\u6563\u53f6\u751f\u83dc","item_price":"4.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"SYSC","stock_id":"87","stock_num":"0","stock_date":"2014-06-05 16:40:43","stock_weight":"0.000"}],[{"item_id":"61","item_no":"0101010003","item_huo":"00003","item_name":"\u6cb9\u9ea6\u83dc","item_price":"4.360","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"YMC","stock_id":"88","stock_num":"0","stock_date":"2014-06-05 16:51:41","stock_weight":"0.000"}],[{"item_id":"62","item_no":"0101010005","item_huo":"00005","item_name":"\u833c\u84bf","item_price":"7.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"TH","stock_id":"89","stock_num":"0","stock_date":"2014-06-05 16:51:45","stock_weight":"0.000"}],[{"item_id":"63","item_no":"0101010006","item_huo":"00006","item_name":"\u82a6\u84bf","item_price":"5.760","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"LH","stock_id":"90","stock_num":"0","stock_date":"2014-06-05 16:51:46","stock_weight":"0.000"}],[{"item_id":"64","item_no":"0101010008","item_huo":"00008","item_name":"\u5c0f\u83e0\u83dc","item_price":"5.960","item_unit":"\u516c\u65a4","item_scale":"\u8ba1\u91cd","item_rem":"XBC","stock_id":"91","stock_num":"0","stock_date":"2014-06-05 16:51:47","stock_weight":"0.000"}]]};

    alert(str.rows);

    for ( var p in str.result ){ // 方法 

        alert(str.result[p][0].item_id);

    }

</script>

很简单的,多用搜索啊哥。。

查看完整回答
反对 回复 2019-04-13
?
智慧大石

TA贡献1946条经验 获得超3个赞

for(var i=0;i<json.result.length;i++){
var jsons=json.result[i];
}

查看完整回答
反对 回复 2019-04-13
  • 2 回答
  • 0 关注
  • 1167 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信