美文网首页
json字符串与json对象之间的转换

json字符串与json对象之间的转换

作者: hello_water | 来源:发表于2017-04-08 13:24 被阅读45次

json字符串:var str = '{'a':1, 'b':2}';

json对象:var obj = {'a':1, 'b':2};

json字符串与json对象之间的转换。

字符串转对象:

JSON.parse(string);

eval('('+string+')');

对象转字符串:

JSON.stringify(obj);

相关文章

网友评论

      本文标题:json字符串与json对象之间的转换

      本文链接:https://www.haomeiwen.com/subject/evvwnttx.html