JS中数组(Array)、Json对象长度(length)获取方法
1.数组
var array = [];
var length = ;
对象
1)方法1:
var pBzjtJson ={"SORT":1,"TITLE":"12324","RANK":1,"TYPE_TAG":"班子集体责任","SR_CLASS_ID":"a2bdfa5b5f684d5d9da5c055117c94c5"};
var length = (pBzjtJson).length;
(length);//5
2)方法2:
function getJsonLength(jsonData){
var jsonLength = 0;
for(var item in jsonData){
jsonLength++;
}
return jsonLength;
}
参考: