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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -