简体   繁体   中英

parsing json format in javascript

{"0":{"name":{"name_id":"How to battle","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"}}}

我想使用解析此json格式。

JSON.parse(json_string);

在较旧的浏览器中,您将需要

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 + ")" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM