var oo = '{"gname":"u5c60u9f99u4f20u8bf4","status":"1","servers":{"29":"u9b54u9f99u4e4bu5fc3","28":"u51e4u821eu4e5du5929","27":"u77f3u7834u5929u60ca","26":"u60cau5929u4e00u5251","25":"u738bu8005u5f52u6765","24":"u55dcu8840u738bu57ce","23":"u5929u9b54u795eu575b","22":"u75afu9b54u4f20u8bf4","21":"u5c60u622eu5929u4e0b","20":"u552fu6211u72ecu5c0a","19":"u9738u6c14u7eb5u6a2a","18":"u88c2u5929u7834u5730","17":"u5929u9f99u6f5cu5f71","16":"u865au65e0u5e7bu6d77","15":"u51e4u51f0u795eu821e","14":"u66dcu65e5u5f00u5929","13":"u7384u5929u90aau5e1d","12":"u5e1du6068u5929u8bdb","11":"u864eu9b44u5929u6676","10":"u5341u65b9u4ff1u706d","9":"u4e07u4e8bu5982u610f","8":"u6218u65e0u4e0du80dc","7":"u9738u738bu522bu59ec","6":"u798fu661fu9ad8u7167","5":"u6d74u706bu91cdu751f","4":"u5144u5f1fu540cu5fc3","3":"u51b3u6218u6c99u57ce","2":"u5929u4ebau5408u4e00","1":"u4f20u5947u5f52u6765"}}'; trim = function(text) { return text == null ? "" : text.replace(/(^s*)|(s*$)/g, ""); }; parseJSON = function(data) { if (!data || typeof data !== "string") { return null; } data = trim(data); if(window.JSON && window.JSON.parse) {console.log(1) return window.JSON.parse(data); } console.log(2); //return (new Function("return " + data))();// 跟下行一个意思 return eval("(" + oo + ")") }; console.log(parseJSON(oo));
输出 : Object {gname: "屠龙传说", status: "1", servers: Object}