{name:"dd",age:"16"} {"name":"dd","age":"16"} 前者是Javascript的对象字面量语法,后者是JSON,后者是前者的一个子集.json中的key必须是用双引号包围的,并且要搞清楚JSON是字符串. 1.eval方式解析,恐怕这是最早的解析方式了.如下: function strToJson(str){ var json = eval('('
//把url的参数部分转化成json对象 parseQueryString: function (url) { var reg_url = /^[^\?]+\?([\w\W]+)$/, reg_para = /([^&=]+)=([\w\W]*?)(&|$|#)/g, arr_url = reg_url.exec(url), ret = {}; if (arr_url && arr_url[1]) { var str_para = arr_url[1], result; w
源码: /* 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