js 获取json数组里面数组的长度

json对象没有length属性

function getJsonLength(jsonData){
//这里一定注意,变量jsonLength要定义在for循环前
var jsonLength = 0;
for(var item in jsonData){
jsonLength++;
}
return jsonLength;
}

上面的方法只能获取到第一层数组的长度

https://www.cnblogs.com/untiring/p/7755455.html

posted @ 2021-12-11 16:52  方寸间  阅读(953)  评论(0)    收藏  举报