mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
Update json2.js to the latest version.
This commit is contained in:
parent
d34f980f37
commit
16e6fdafcd
1 changed files with 19 additions and 21 deletions
40
lib/json2.js
40
lib/json2.js
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
json2.js
|
||||
2011-10-19
|
||||
2014-02-04
|
||||
|
||||
Public Domain.
|
||||
|
||||
|
|
@ -159,8 +159,7 @@
|
|||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
var JSON;
|
||||
if (!JSON) {
|
||||
if (typeof JSON !== 'object') {
|
||||
JSON = {};
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +173,7 @@ if (!JSON) {
|
|||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
/** @ignore */
|
||||
Date.prototype.toJSON = function (key) {
|
||||
Date.prototype.toJSON = function () {
|
||||
|
||||
return isFinite(this.valueOf())
|
||||
? this.getUTCFullYear() + '-' +
|
||||
|
|
@ -189,25 +187,16 @@ if (!JSON) {
|
|||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
/** @ignore */
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
Boolean.prototype.toJSON = function () {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
var cx,
|
||||
escapable,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
meta,
|
||||
rep;
|
||||
|
||||
|
||||
|
|
@ -359,7 +348,16 @@ if (!JSON) {
|
|||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
/** @ignore */
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
|
|
@ -407,7 +405,7 @@ if (!JSON) {
|
|||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
/** @ignore */
|
||||
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
|
|
@ -488,4 +486,4 @@ if (!JSON) {
|
|||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||
}());
|
||||
|
|
|
|||
Loading…
Reference in a new issue