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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -