将json字符串转换为json对象

一般处理服务器传来的json值时,我们都会用两种方式进行处理:

1.一种为使用eval()函数。var dataObj=eval("("+data+")");//转换为json对象(注:data为json数据);

2. 使用Function对象来进行返回解析。var json =(new Function("","return "+data))();

转载自:http://www.php.cn/js-tutorial-382630.html

猜你喜欢

转载自blog.csdn.net/weixin_38383877/article/details/81669058
今日推荐