Parse 2 dimensional JSON array in Javascript

Posted by MrG on Stack Overflow See other posts from Stack Overflow or by MrG
Published on 2010-03-21T18:19:01Z Indexed on 2010/03/21 18:21 UTC
Read the original article Hit count: 324

Filed under:
|

I have a two dimensional JSON array where each element contains several attributes. The example below is intentionally simplified:

var map_data = { "1":
                      {"1":{"name":"aa"},"2":{"name":"bb"}},
                 "2":
                      {"1":{"name":"cc"},"2":{"name":"dd"}}
               };

I try to parse the data but .length doesn't work:

for(x=1; x<=map_data.length; x++) { 
    for(y=1; y<=map_data[x].length; y++) {
        // CODE 
    }
}

Many, many thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about JSON