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

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -