views:

108

answers:

3

{"some_id": [ {"city":"Bellevue"}, {"state":"Washington"} ] }

+3  A: 
var json = {"some_id": [ {"city":"Bellevue"}, {"state":"Washington"} ] }

json.some_id[0].city equals "Bellevue"

and

json.some_id[1].state equals "Washington"

GerManson
+5  A: 
var theJSonString = '({"some_id": [ {"city":"Bellevue"}, {"state":"Washington"} ] })';
var x = eval(theJSonString);
alert(x.some_id[0].city); // will display "Bellevue"
DanC
If you parse JSON with `eval`, you need to wrap the contents in parentheses (e.g. `eval('(' + theString + ')')`), otherwise it gets parsed as a block statement instead of an object literal.
Matthew Crumley
Added missing parenthesis. Thanks @Matthew Crumley
DanC
+1  A: 

And this (the json parser and stringifier from json.org) might help :) (check the link at the bottom of the page)

Dan Heberden