参考:http://www.cnblogs.com/youring2/archive/2013/03/01/2938850.html
github地址:https://github.com/douglascrockford/JSON-js
序列化,json对象化转string
var jsonObj = { id: ‘1‘, name: ‘Tom Green‘ }; var jsonStr=JSON.stringify(jsonObj)
输出结果:{"id":"1","name":"Tom Green"}
反序列化 string 转json 对象
var jsonString = ‘{ "id": "01", "name": "Tom Green" }‘; var jsonObj = JSON.parse(jsonString);
输出:Object { id="01", name="Tom"}
时间: 2024-11-07 15:40:58