treating json like an array

Posted by tawheed on Stack Overflow See other posts from Stack Overflow or by tawheed
Published on 2012-04-14T05:20:47Z Indexed on 2012/04/14 5:29 UTC
Read the original article Hit count: 289

Filed under:

I was doing some test with json and ran into serveral issues. hope somebody on this mailing list can help out.

localStorage[LOC] = JSON.stringify(track);
            var boy = localStorage[LOC];
            alert(boy);

This is the data I get back

[{"lat":42.5877511,"lng":-71.7873177,"acc":67,"date":"Sat Apr 14 2012 01:03:46 GMT-0400 (EDT)"}]

I was wondering how I could access the json objects like we do in a regular array.

For debugging purposes I did something like,

alert(boy[0].lat);

But the result I got back was undefined

© Stack Overflow or respective owner

Related posts about JSON