字符串转对象(strJSON代表json字符串) var obj = eval(strJSON); var obj = strJSON.parseJSON(); var obj = JSON.parse(strJSON): json对象转字符串(obj代表json对象) var str = obj.toJSONString(); var str = JSON.stringify(obj) 运用时候需要除了eval()以外需要json.js包(切记哦)
源码: /* http://www.JSON.org/json2.js 2010-03-20 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. See http://www.JSON.org/js.html This code should be minified before deployment. See http://javascript.crockford.com/jsmin.html USE Y