假設json為:
Json代碼
[{"name":'a',"age":1,"sex":"0","title":"hello","state":"0 ","id":"1"},{"name":'b',"age":2,"sex":"1","title":"bye","state":"0", "id":"2"}]
以下是取得json物件的長度的方法:
Js程式碼
function getJsonObj1ength(jsonOb
for (var item in jsonObj ) {
Length++;
}
到。
Js程式碼 alert(getJsonObjLength(str)) //2
= = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = 詞
= = = = = = = = = = = = = = = = = = = = = //a, b
alert(json[key]); //12, 45
}