Advertise with us

Nested Arrays

Nested Arrays in JSON Objects ?

Last updated:7/3/2018 4:25:04 AM

1 Answers

Prakash nidhi Verma
Prakash nidhi Verma

Arrays as JSON Objects :

JSON array are almost the same as arrays in JS. Values must be string, number, object, array, boolean or null type in JSON array. 

Example : 

[ "Allahabad", "Kanpur", "Varansi" ]

Array values by using a for-in loop: 

for (i in { 
    x +=[i];

Nested Arrays in JSON Objects: 

myObj = { 
    "city": [
        { "name":"Allahabad", "models":[ "Sangam"] },
        { "name":"Kanpur", "models":[ "Industrial"] },
        { "name":"Varansi", "models":[ "Devnagari" ] }
delete[1];    //Delete array