<!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
时间: 2024-10-09 03:16:27