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

<!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>

转载于:https://www.cnblogs.com/lsc-boke/p/10996922.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值