开发者

parsing json format in javascript

{"0":{"name":{"name_id":"How to batt开发者_高级运维le","tab_level":"2"},"job_reward":{"job_money":"10000","job_exp":"50","job_energy":"23"}},"job_required_items":[{"filename":"sword.gif","no":"2"}],"1":{"name":{"name_id":"Check for battle","tab_level":"2"},"job_reward":{"job_money":"1000","job_exp":"12","job_energy":"10"}}}

i want to parse this json format using for.


JSON.parse(json_string);

in older browsers you'll need this


In modern browsers you can do:

JSON.parse(json);

If you want it to work for older ones you may consider using the offical parser from json.org.

If the response is from you, you can parse it natively by:

var o = new Function( "return " + json )();

which is even faster than the usual:

var o = eval( "(" + json + ")" );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜