json数组嵌套数组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json数组嵌套数组相关的知识,希望对你有一定的参考价值。

[
[

"id": 24,
"sort": "家常菜",
"dishes": "西红柿茭白",
"price": "15",
"image": "cp1.jpg",
"assess": 3,
"assessfrequency": 8,
"star": "2star.png",
"characteristic": "1"

],
[

"id": 29,
"sort": "凉菜",
"dishes": "东北大拌菜",
"price": "22",
"image": "cp1.jpg",
"assess": 3,
"assessfrequency": 8,
"star": "2star.png",
"characteristic": "0"
,

"id": 28,
"sort": "凉菜",
"dishes": "凉拌海蜇",
"price": "13",
"image": "cp1.jpg",
"assess": 3,
"assessfrequency": 8,
"star": "2star.png",
"characteristic": "0"
,

"id": 27,
"sort": "凉菜",
"dishes": "蒜泥白肉",
"price": "17",
"image": "cp1.jpg",
"assess": 3,
"assessfrequency": 8,
"star": "2star.png",
"characteristic": "1"

]
]
怎么解析,分不是问题快来人解答

假定你这个数组变量名为:jsonarr

for (var i = 0; i < jsonarr.length; i++) 
            var b = jsonarr[i];
            for (var j = 0; j < b.length; j++) 
                //可循环遍历
                for (var x in b[j]) 
                    console.log(x, "=", b[j][x]);
                
                //或用下面的直接取对应key
                console.log(b[j].id)
                console.log(b[j].sort)
                console.log(b[j].dishes)
                console.log(b[j].price)
                console.log(b[j].image)
                console.log(b[j].assess)
                console.log(b[j].assessfrequency)
                console.log(b[j].star)
                console.log(b[j].characteristic)
            
        

参考技术A josn数组里包含多个json对象

以上是关于json数组嵌套数组的主要内容,如果未能解决你的问题,请参考以下文章

sql解析嵌套json+数组

sql解析嵌套json+数组

sql解析嵌套json+数组

Athena 在另一个 json 结构数组中未嵌套 json 字符串数组

Angular 2 *ngFor的数组/ json渲染中的深层嵌套json到数组[重复]

将 Json 数组嵌套到对象