json转成string[需要引用json2.js文件]:
复制代码 代码如下:
var arr=[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}];
var str=JSON.stringify(arr);
结果:"[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]"
string转化为json:
复制代码 代码如下:
var str="[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]";
var json=$.parseJSON(str);
结果:[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]
复制代码 代码如下:
var arr=[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}];
var str=JSON.stringify(arr);
结果:"[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]"
string转化为json:
复制代码 代码如下:
var str="[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]";
var json=$.parseJSON(str);
结果:[{id:'id',name:'Spring'},{id:'id2',name:'Jane'}]
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“json数据与字符串的相互转化示例”评论...