How to count JSON objects
You can use the following solution to count JSON objects:
var jsonObject = {"test1":1,"test2":2};
var keyCount = Object.keys(jsonObject).length;
That's an array.
You can parse it (JSON.parse
), then use the length
property.
Assuming it's in the variable foo
, foo.length
.
var foo = [{...},{...},...];
alert(foo.length);
foo[0].id// 38;