Edit File by line
/home/barbar84/www/wp-inclu.../js
File: json2.js
/*
[0] Fix | Delete
json2.js
[1] Fix | Delete
2015-05-03
[2] Fix | Delete
[3] Fix | Delete
Public Domain.
[4] Fix | Delete
[5] Fix | Delete
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
[6] Fix | Delete
[7] Fix | Delete
See http://www.JSON.org/js.html
[8] Fix | Delete
[9] Fix | Delete
[10] Fix | Delete
This code should be minified before deployment.
[11] Fix | Delete
See http://javascript.crockford.com/jsmin.html
[12] Fix | Delete
[13] Fix | Delete
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
[14] Fix | Delete
NOT CONTROL.
[15] Fix | Delete
[16] Fix | Delete
[17] Fix | Delete
This file creates a global JSON object containing two methods: stringify
[18] Fix | Delete
and parse. This file is provides the ES5 JSON capability to ES3 systems.
[19] Fix | Delete
If a project might run on IE8 or earlier, then this file should be included.
[20] Fix | Delete
This file does nothing on ES5 systems.
[21] Fix | Delete
[22] Fix | Delete
JSON.stringify(value, replacer, space)
[23] Fix | Delete
value any JavaScript value, usually an object or array.
[24] Fix | Delete
[25] Fix | Delete
replacer an optional parameter that determines how object
[26] Fix | Delete
values are stringified for objects. It can be a
[27] Fix | Delete
function or an array of strings.
[28] Fix | Delete
[29] Fix | Delete
space an optional parameter that specifies the indentation
[30] Fix | Delete
of nested structures. If it is omitted, the text will
[31] Fix | Delete
be packed without extra whitespace. If it is a number,
[32] Fix | Delete
it will specify the number of spaces to indent at each
[33] Fix | Delete
level. If it is a string (such as '\t' or ' '),
[34] Fix | Delete
it contains the characters used to indent at each level.
[35] Fix | Delete
[36] Fix | Delete
This method produces a JSON text from a JavaScript value.
[37] Fix | Delete
[38] Fix | Delete
When an object value is found, if the object contains a toJSON
[39] Fix | Delete
method, its toJSON method will be called and the result will be
[40] Fix | Delete
stringified. A toJSON method does not serialize: it returns the
[41] Fix | Delete
value represented by the name/value pair that should be serialized,
[42] Fix | Delete
or undefined if nothing should be serialized. The toJSON method
[43] Fix | Delete
will be passed the key associated with the value, and this will be
[44] Fix | Delete
bound to the value
[45] Fix | Delete
[46] Fix | Delete
For example, this would serialize Dates as ISO strings.
[47] Fix | Delete
[48] Fix | Delete
Date.prototype.toJSON = function (key) {
[49] Fix | Delete
function f(n) {
[50] Fix | Delete
// Format integers to have at least two digits.
[51] Fix | Delete
return n < 10
[52] Fix | Delete
? '0' + n
[53] Fix | Delete
: n;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
return this.getUTCFullYear() + '-' +
[57] Fix | Delete
f(this.getUTCMonth() + 1) + '-' +
[58] Fix | Delete
f(this.getUTCDate()) + 'T' +
[59] Fix | Delete
f(this.getUTCHours()) + ':' +
[60] Fix | Delete
f(this.getUTCMinutes()) + ':' +
[61] Fix | Delete
f(this.getUTCSeconds()) + 'Z';
[62] Fix | Delete
};
[63] Fix | Delete
[64] Fix | Delete
You can provide an optional replacer method. It will be passed the
[65] Fix | Delete
key and value of each member, with this bound to the containing
[66] Fix | Delete
object. The value that is returned from your method will be
[67] Fix | Delete
serialized. If your method returns undefined, then the member will
[68] Fix | Delete
be excluded from the serialization.
[69] Fix | Delete
[70] Fix | Delete
If the replacer parameter is an array of strings, then it will be
[71] Fix | Delete
used to select the members to be serialized. It filters the results
[72] Fix | Delete
such that only members with keys listed in the replacer array are
[73] Fix | Delete
stringified.
[74] Fix | Delete
[75] Fix | Delete
Values that do not have JSON representations, such as undefined or
[76] Fix | Delete
functions, will not be serialized. Such values in objects will be
[77] Fix | Delete
dropped; in arrays they will be replaced with null. You can use
[78] Fix | Delete
a replacer function to replace those with JSON values.
[79] Fix | Delete
JSON.stringify(undefined) returns undefined.
[80] Fix | Delete
[81] Fix | Delete
The optional space parameter produces a stringification of the
[82] Fix | Delete
value that is filled with line breaks and indentation to make it
[83] Fix | Delete
easier to read.
[84] Fix | Delete
[85] Fix | Delete
If the space parameter is a non-empty string, then that string will
[86] Fix | Delete
be used for indentation. If the space parameter is a number, then
[87] Fix | Delete
the indentation will be that many spaces.
[88] Fix | Delete
[89] Fix | Delete
Example:
[90] Fix | Delete
[91] Fix | Delete
text = JSON.stringify(['e', {pluribus: 'unum'}]);
[92] Fix | Delete
// text is '["e",{"pluribus":"unum"}]'
[93] Fix | Delete
[94] Fix | Delete
[95] Fix | Delete
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
[96] Fix | Delete
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
[97] Fix | Delete
[98] Fix | Delete
text = JSON.stringify([new Date()], function (key, value) {
[99] Fix | Delete
return this[key] instanceof Date
[100] Fix | Delete
? 'Date(' + this[key] + ')'
[101] Fix | Delete
: value;
[102] Fix | Delete
});
[103] Fix | Delete
// text is '["Date(---current time---)"]'
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
JSON.parse(text, reviver)
[107] Fix | Delete
This method parses a JSON text to produce an object or array.
[108] Fix | Delete
It can throw a SyntaxError exception.
[109] Fix | Delete
[110] Fix | Delete
The optional reviver parameter is a function that can filter and
[111] Fix | Delete
transform the results. It receives each of the keys and values,
[112] Fix | Delete
and its return value is used instead of the original value.
[113] Fix | Delete
If it returns what it received, then the structure is not modified.
[114] Fix | Delete
If it returns undefined then the member is deleted.
[115] Fix | Delete
[116] Fix | Delete
Example:
[117] Fix | Delete
[118] Fix | Delete
// Parse the text. Values that look like ISO date strings will
[119] Fix | Delete
// be converted to Date objects.
[120] Fix | Delete
[121] Fix | Delete
myData = JSON.parse(text, function (key, value) {
[122] Fix | Delete
var a;
[123] Fix | Delete
if (typeof value === 'string') {
[124] Fix | Delete
a =
[125] Fix | Delete
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
[126] Fix | Delete
if (a) {
[127] Fix | Delete
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
[128] Fix | Delete
+a[5], +a[6]));
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
return value;
[132] Fix | Delete
});
[133] Fix | Delete
[134] Fix | Delete
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
[135] Fix | Delete
var d;
[136] Fix | Delete
if (typeof value === 'string' &&
[137] Fix | Delete
value.slice(0, 5) === 'Date(' &&
[138] Fix | Delete
value.slice(-1) === ')') {
[139] Fix | Delete
d = new Date(value.slice(5, -1));
[140] Fix | Delete
if (d) {
[141] Fix | Delete
return d;
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
return value;
[145] Fix | Delete
});
[146] Fix | Delete
[147] Fix | Delete
[148] Fix | Delete
This is a reference implementation. You are free to copy, modify, or
[149] Fix | Delete
redistribute.
[150] Fix | Delete
*/
[151] Fix | Delete
[152] Fix | Delete
/*jslint
[153] Fix | Delete
eval, for, this
[154] Fix | Delete
*/
[155] Fix | Delete
[156] Fix | Delete
/*property
[157] Fix | Delete
JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
[158] Fix | Delete
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
[159] Fix | Delete
lastIndex, length, parse, prototype, push, replace, slice, stringify,
[160] Fix | Delete
test, toJSON, toString, valueOf
[161] Fix | Delete
*/
[162] Fix | Delete
[163] Fix | Delete
[164] Fix | Delete
// Create a JSON object only if one does not already exist. We create the
[165] Fix | Delete
// methods in a closure to avoid creating global variables.
[166] Fix | Delete
[167] Fix | Delete
if (typeof JSON !== 'object') {
[168] Fix | Delete
JSON = {};
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
(function () {
[172] Fix | Delete
'use strict';
[173] Fix | Delete
[174] Fix | Delete
var rx_one = /^[\],:{}\s]*$/,
[175] Fix | Delete
rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
[176] Fix | Delete
rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
[177] Fix | Delete
rx_four = /(?:^|:|,)(?:\s*\[)+/g,
[178] Fix | Delete
rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
[179] Fix | Delete
rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
[180] Fix | Delete
[181] Fix | Delete
function f(n) {
[182] Fix | Delete
// Format integers to have at least two digits.
[183] Fix | Delete
return n < 10
[184] Fix | Delete
? '0' + n
[185] Fix | Delete
: n;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
function this_value() {
[189] Fix | Delete
return this.valueOf();
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
if (typeof Date.prototype.toJSON !== 'function') {
[193] Fix | Delete
[194] Fix | Delete
Date.prototype.toJSON = function () {
[195] Fix | Delete
[196] Fix | Delete
return isFinite(this.valueOf())
[197] Fix | Delete
? this.getUTCFullYear() + '-' +
[198] Fix | Delete
f(this.getUTCMonth() + 1) + '-' +
[199] Fix | Delete
f(this.getUTCDate()) + 'T' +
[200] Fix | Delete
f(this.getUTCHours()) + ':' +
[201] Fix | Delete
f(this.getUTCMinutes()) + ':' +
[202] Fix | Delete
f(this.getUTCSeconds()) + 'Z'
[203] Fix | Delete
: null;
[204] Fix | Delete
};
[205] Fix | Delete
[206] Fix | Delete
Boolean.prototype.toJSON = this_value;
[207] Fix | Delete
Number.prototype.toJSON = this_value;
[208] Fix | Delete
String.prototype.toJSON = this_value;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
var gap,
[212] Fix | Delete
indent,
[213] Fix | Delete
meta,
[214] Fix | Delete
rep;
[215] Fix | Delete
[216] Fix | Delete
[217] Fix | Delete
function quote(string) {
[218] Fix | Delete
[219] Fix | Delete
// If the string contains no control characters, no quote characters, and no
[220] Fix | Delete
// backslash characters, then we can safely slap some quotes around it.
[221] Fix | Delete
// Otherwise we must also replace the offending characters with safe escape
[222] Fix | Delete
// sequences.
[223] Fix | Delete
[224] Fix | Delete
rx_escapable.lastIndex = 0;
[225] Fix | Delete
return rx_escapable.test(string)
[226] Fix | Delete
? '"' + string.replace(rx_escapable, function (a) {
[227] Fix | Delete
var c = meta[a];
[228] Fix | Delete
return typeof c === 'string'
[229] Fix | Delete
? c
[230] Fix | Delete
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
[231] Fix | Delete
}) + '"'
[232] Fix | Delete
: '"' + string + '"';
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
[236] Fix | Delete
function str(key, holder) {
[237] Fix | Delete
[238] Fix | Delete
// Produce a string from holder[key].
[239] Fix | Delete
[240] Fix | Delete
var i, // The loop counter.
[241] Fix | Delete
k, // The member key.
[242] Fix | Delete
v, // The member value.
[243] Fix | Delete
length,
[244] Fix | Delete
mind = gap,
[245] Fix | Delete
partial,
[246] Fix | Delete
value = holder[key];
[247] Fix | Delete
[248] Fix | Delete
// If the value has a toJSON method, call it to obtain a replacement value.
[249] Fix | Delete
[250] Fix | Delete
if (value && typeof value === 'object' &&
[251] Fix | Delete
typeof value.toJSON === 'function') {
[252] Fix | Delete
value = value.toJSON(key);
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
// If we were called with a replacer function, then call the replacer to
[256] Fix | Delete
// obtain a replacement value.
[257] Fix | Delete
[258] Fix | Delete
if (typeof rep === 'function') {
[259] Fix | Delete
value = rep.call(holder, key, value);
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
// What happens next depends on the value's type.
[263] Fix | Delete
[264] Fix | Delete
switch (typeof value) {
[265] Fix | Delete
case 'string':
[266] Fix | Delete
return quote(value);
[267] Fix | Delete
[268] Fix | Delete
case 'number':
[269] Fix | Delete
[270] Fix | Delete
// JSON numbers must be finite. Encode non-finite numbers as null.
[271] Fix | Delete
[272] Fix | Delete
return isFinite(value)
[273] Fix | Delete
? String(value)
[274] Fix | Delete
: 'null';
[275] Fix | Delete
[276] Fix | Delete
case 'boolean':
[277] Fix | Delete
case 'null':
[278] Fix | Delete
[279] Fix | Delete
// If the value is a boolean or null, convert it to a string. Note:
[280] Fix | Delete
// typeof null does not produce 'null'. The case is included here in
[281] Fix | Delete
// the remote chance that this gets fixed someday.
[282] Fix | Delete
[283] Fix | Delete
return String(value);
[284] Fix | Delete
[285] Fix | Delete
// If the type is 'object', we might be dealing with an object or an array or
[286] Fix | Delete
// null.
[287] Fix | Delete
[288] Fix | Delete
case 'object':
[289] Fix | Delete
[290] Fix | Delete
// Due to a specification blunder in ECMAScript, typeof null is 'object',
[291] Fix | Delete
// so watch out for that case.
[292] Fix | Delete
[293] Fix | Delete
if (!value) {
[294] Fix | Delete
return 'null';
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
// Make an array to hold the partial results of stringifying this object value.
[298] Fix | Delete
[299] Fix | Delete
gap += indent;
[300] Fix | Delete
partial = [];
[301] Fix | Delete
[302] Fix | Delete
// Is the value an array?
[303] Fix | Delete
[304] Fix | Delete
if (Object.prototype.toString.apply(value) === '[object Array]') {
[305] Fix | Delete
[306] Fix | Delete
// The value is an array. Stringify every element. Use null as a placeholder
[307] Fix | Delete
// for non-JSON values.
[308] Fix | Delete
[309] Fix | Delete
length = value.length;
[310] Fix | Delete
for (i = 0; i < length; i += 1) {
[311] Fix | Delete
partial[i] = str(i, value) || 'null';
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
// Join all of the elements together, separated with commas, and wrap them in
[315] Fix | Delete
// brackets.
[316] Fix | Delete
[317] Fix | Delete
v = partial.length === 0
[318] Fix | Delete
? '[]'
[319] Fix | Delete
: gap
[320] Fix | Delete
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
[321] Fix | Delete
: '[' + partial.join(',') + ']';
[322] Fix | Delete
gap = mind;
[323] Fix | Delete
return v;
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
// If the replacer is an array, use it to select the members to be stringified.
[327] Fix | Delete
[328] Fix | Delete
if (rep && typeof rep === 'object') {
[329] Fix | Delete
length = rep.length;
[330] Fix | Delete
for (i = 0; i < length; i += 1) {
[331] Fix | Delete
if (typeof rep[i] === 'string') {
[332] Fix | Delete
k = rep[i];
[333] Fix | Delete
v = str(k, value);
[334] Fix | Delete
if (v) {
[335] Fix | Delete
partial.push(quote(k) + (
[336] Fix | Delete
gap
[337] Fix | Delete
? ': '
[338] Fix | Delete
: ':'
[339] Fix | Delete
) + v);
[340] Fix | Delete
}
[341] Fix | Delete
}
[342] Fix | Delete
}
[343] Fix | Delete
} else {
[344] Fix | Delete
[345] Fix | Delete
// Otherwise, iterate through all of the keys in the object.
[346] Fix | Delete
[347] Fix | Delete
for (k in value) {
[348] Fix | Delete
if (Object.prototype.hasOwnProperty.call(value, k)) {
[349] Fix | Delete
v = str(k, value);
[350] Fix | Delete
if (v) {
[351] Fix | Delete
partial.push(quote(k) + (
[352] Fix | Delete
gap
[353] Fix | Delete
? ': '
[354] Fix | Delete
: ':'
[355] Fix | Delete
) + v);
[356] Fix | Delete
}
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
// Join all of the member texts together, separated with commas,
[362] Fix | Delete
// and wrap them in braces.
[363] Fix | Delete
[364] Fix | Delete
v = partial.length === 0
[365] Fix | Delete
? '{}'
[366] Fix | Delete
: gap
[367] Fix | Delete
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
[368] Fix | Delete
: '{' + partial.join(',') + '}';
[369] Fix | Delete
gap = mind;
[370] Fix | Delete
return v;
[371] Fix | Delete
}
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
// If the JSON object does not yet have a stringify method, give it one.
[375] Fix | Delete
[376] Fix | Delete
if (typeof JSON.stringify !== 'function') {
[377] Fix | Delete
meta = { // table of character substitutions
[378] Fix | Delete
'\b': '\\b',
[379] Fix | Delete
'\t': '\\t',
[380] Fix | Delete
'\n': '\\n',
[381] Fix | Delete
'\f': '\\f',
[382] Fix | Delete
'\r': '\\r',
[383] Fix | Delete
'"': '\\"',
[384] Fix | Delete
'\\': '\\\\'
[385] Fix | Delete
};
[386] Fix | Delete
JSON.stringify = function (value, replacer, space) {
[387] Fix | Delete
[388] Fix | Delete
// The stringify method takes a value and an optional replacer, and an optional
[389] Fix | Delete
// space parameter, and returns a JSON text. The replacer can be a function
[390] Fix | Delete
// that can replace values, or an array of strings that will select the keys.
[391] Fix | Delete
// A default replacer method can be provided. Use of the space parameter can
[392] Fix | Delete
// produce text that is more easily readable.
[393] Fix | Delete
[394] Fix | Delete
var i;
[395] Fix | Delete
gap = '';
[396] Fix | Delete
indent = '';
[397] Fix | Delete
[398] Fix | Delete
// If the space parameter is a number, make an indent string containing that
[399] Fix | Delete
// many spaces.
[400] Fix | Delete
[401] Fix | Delete
if (typeof space === 'number') {
[402] Fix | Delete
for (i = 0; i < space; i += 1) {
[403] Fix | Delete
indent += ' ';
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
// If the space parameter is a string, it will be used as the indent string.
[407] Fix | Delete
[408] Fix | Delete
} else if (typeof space === 'string') {
[409] Fix | Delete
indent = space;
[410] Fix | Delete
}
[411] Fix | Delete
[412] Fix | Delete
// If there is a replacer, it must be a function or an array.
[413] Fix | Delete
// Otherwise, throw an error.
[414] Fix | Delete
[415] Fix | Delete
rep = replacer;
[416] Fix | Delete
if (replacer && typeof replacer !== 'function' &&
[417] Fix | Delete
(typeof replacer !== 'object' ||
[418] Fix | Delete
typeof replacer.length !== 'number')) {
[419] Fix | Delete
throw new Error('JSON.stringify');
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
// Make a fake root object containing our value under the key of ''.
[423] Fix | Delete
// Return the result of stringifying the value.
[424] Fix | Delete
[425] Fix | Delete
return str('', {'': value});
[426] Fix | Delete
};
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
[430] Fix | Delete
// If the JSON object does not yet have a parse method, give it one.
[431] Fix | Delete
[432] Fix | Delete
if (typeof JSON.parse !== 'function') {
[433] Fix | Delete
JSON.parse = function (text, reviver) {
[434] Fix | Delete
[435] Fix | Delete
// The parse method takes a text and an optional reviver function, and returns
[436] Fix | Delete
// a JavaScript value if the text is a valid JSON text.
[437] Fix | Delete
[438] Fix | Delete
var j;
[439] Fix | Delete
[440] Fix | Delete
function walk(holder, key) {
[441] Fix | Delete
[442] Fix | Delete
// The walk method is used to recursively walk the resulting structure so
[443] Fix | Delete
// that modifications can be made.
[444] Fix | Delete
[445] Fix | Delete
var k, v, value = holder[key];
[446] Fix | Delete
if (value && typeof value === 'object') {
[447] Fix | Delete
for (k in value) {
[448] Fix | Delete
if (Object.prototype.hasOwnProperty.call(value, k)) {
[449] Fix | Delete
v = walk(value, k);
[450] Fix | Delete
if (v !== undefined) {
[451] Fix | Delete
value[k] = v;
[452] Fix | Delete
} else {
[453] Fix | Delete
delete value[k];
[454] Fix | Delete
}
[455] Fix | Delete
}
[456] Fix | Delete
}
[457] Fix | Delete
}
[458] Fix | Delete
return reviver.call(holder, key, value);
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
[462] Fix | Delete
// Parsing happens in four stages. In the first stage, we replace certain
[463] Fix | Delete
// Unicode characters with escape sequences. JavaScript handles many characters
[464] Fix | Delete
// incorrectly, either silently deleting them, or treating them as line endings.
[465] Fix | Delete
[466] Fix | Delete
text = String(text);
[467] Fix | Delete
rx_dangerous.lastIndex = 0;
[468] Fix | Delete
if (rx_dangerous.test(text)) {
[469] Fix | Delete
text = text.replace(rx_dangerous, function (a) {
[470] Fix | Delete
return '\\u' +
[471] Fix | Delete
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
[472] Fix | Delete
});
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
// In the second stage, we run the text against regular expressions that look
[476] Fix | Delete
// for non-JSON patterns. We are especially concerned with '()' and 'new'
[477] Fix | Delete
// because they can cause invocation, and '=' because it can cause mutation.
[478] Fix | Delete
// But just to be safe, we want to reject all unexpected forms.
[479] Fix | Delete
[480] Fix | Delete
// We split the second stage into 4 regexp operations in order to work around
[481] Fix | Delete
// crippling inefficiencies in IE's and Safari's regexp engines. First we
[482] Fix | Delete
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
[483] Fix | Delete
// replace all simple value tokens with ']' characters. Third, we delete all
[484] Fix | Delete
// open brackets that follow a colon or comma or that begin the text. Finally,
[485] Fix | Delete
// we look to see that the remaining characters are only whitespace or ']' or
[486] Fix | Delete
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
[487] Fix | Delete
[488] Fix | Delete
if (
[489] Fix | Delete
rx_one.test(
[490] Fix | Delete
text
[491] Fix | Delete
.replace(rx_two, '@')
[492] Fix | Delete
.replace(rx_three, ']')
[493] Fix | Delete
.replace(rx_four, '')
[494] Fix | Delete
)
[495] Fix | Delete
) {
[496] Fix | Delete
[497] Fix | Delete
// In the third stage we use the eval function to compile the text into a
[498] Fix | Delete
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function