开发者

parsing json format in javascript

开发者 https://www.devze.com 2023-01-06 18:28 出处:网络
{\"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\":[{\"filena
{"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

精彩评论

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