开发者

Iterate JSON string

I have a JSON string like this

{"3开发者_如何学JAVA560" : "something", "3980" : "something", "4580" : "1456"}

How to get data above as "key -> value" in javascript(jquery) ?


var obj = JSON.parse(jsonString);

Now you can access obj["3560"], etc.

Or iterating:

for(var key in obj) {
    // do something with obj[key]
}


var obj = jQuery.parseJSON(jsonObj);

Then you could access the data like obj.3560 or obj.3980 or iterate over them using a for-in loop like in Felix Kling's answer.

This requires jquery 1.4.1 or later to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜