日期:2014-05-16 浏览次数:20416 次
/*
---
name: JSON
description: JSON encoder and decoder.
Copy from mootools 1.4.5
license: MIT-style license.
SeeAlso: <http://www.json.org/>
requires: [Array, String, Number, Function]
provides: JSON
...
*/
if (typeof JSON == 'undefined') this.JSON = {};
var special = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'};
var escape = function(chr){
return special[chr]
------解决方案--------------------
'\\u' + ('0000' + chr.charCodeAt(0).toString(16)).slice(-4);
};
JSON.validate = function(string){
string = string.replace(/\\(?:["\\\/bfnrt]
------解决方案--------------------
u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"
------解决方案--------------------
true
------解决方案--------------------
false
------解决方案--------------------
null
------解决方案--------------------
-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^
------解决方案--------------------