码迷,mamicode.com
首页 > Web开发 > 详细

二维json 遍历取值(前端网备份)

时间:2019-06-10 13:33:44      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:for   asc   code   operator   name   fun   pre   ref   viewport   

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>111</title>

</head>

<body class="gray-bg">

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
    var obj ={"total":2,"data":[{"cardDevices":[{"brand":"品牌1","id":"1","number":"21001","type":"ic","version":"1.0","window":{"$ref":"$.data[0]"}}],"id":"1","name":"1号窗口","number":"1001","operator":"张三","phone":"111111111","restaurant":"1号餐厅"},{"cardDevices":[{"brand":"品牌1","id":"2","number":"21002","type":"ic","version":"1.0","window":{"$ref":"$.data[1]"}}],"id":"2","name":"2号窗口","number":"1002","operator":"李四","phone":"12312312312","restaurant":"2号餐厅"}]}
    /*var newarr = obj.data;
    newarr.forEach(function(value,index){
        console.log(value.cardDevices[0].number)
    })*/
    for( i in obj){
        console.log(‘i‘,i);
                var val=obj[i];
                for( j in val){
                    //console.log(‘j‘,j);
                    console.log(val[j].cardDevices[0].number)
                }
            }
})
</script>

</body>
</html>

二维json 遍历取值(前端网备份)

标签:for   asc   code   operator   name   fun   pre   ref   viewport   

原文地址:https://www.cnblogs.com/lsc-boke/p/10996922.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!