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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -