Jquery get length of json array -
i've issue json array row length...
i want extract correct length of data-row json (in case "2")... if try count length value "1". why ? how can correct length ?
{ "data-row": { "data1": [{ "firstname": "john", "lastname": "doe" }, { "firstname": "anna", "lastname": "smith" }, { "firstname": "peter", "lastname": "jones" }], "data2": [{ "firstname": "john", "lastname": "doe" }, { "firstname": "anna", "lastname": "smith" }] } }
you have object
, find length of object
var json = { "data-row": { "data1": [], "data2": [] } } alert(object.keys(json["data-row"]).length);
as having -
in key
use json["data-row"]
access object
Comments
Post a Comment