本文介绍了从JSON字符串获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下JSON字符串:
I have the following JSON string:
{"d":"{\"Foo\":7,\"Bar\":5,\"Foobar\":3}"}以及我的js文件中的相应调用:
And the corresponding invocation in my js file:
$.getJSON("Foo.svc/GetSomeFoo", function (response) { alert(response["Foo"]); alert(response["Bar"]); alert(response["Foobar"]); });只是尝试写出值,但似乎无法将其写出. 这可能很简单,但是在谷歌搜索时找不到任何有用的东西.
Just trying to write out the values, but can't seem to get it out. It is probably very simple, but I am not finding anything helpful while googling it.
推荐答案您的JSON已嵌入JSON.您需要这样做:
Your JSON has embedded JSON. You need to do:
var d = JSON.parse(response.d); alert(d.Foo); ...更多推荐
从JSON字符串获取值
发布评论