jquery - Get value from JSON string -


i have following json string:

{"d":"{\"foo\":7,\"bar\":5,\"foobar\":3}"} 

and corresponding invocation in js file:

$.getjson("foo.svc/getsomefoo", function (response) {             alert(response["foo"]);             alert(response["bar"]);             alert(response["foobar"]);         }); 

just trying write out values, can't seem out. simple, not finding helpful while googling it.

your json has embedded json. need do:

var d = json.parse(response.d); alert(d.foo); ... 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -