//JSON下面的数组有长度 var json1={"abc":[{"name":"txt1"},{"name","txt2"}]}; for(var i=0;i<json1.abc.length;i++){alert(json1.abc[i].name);} //json本身没有length属性 var json2={"name":"txt1","name2":"txt2"};
//获取Json的length function getJsonLength(jsonData){ var jsonLength = 0; for(var item in jsonData){ jsonLength++; } return jsonLength; }