Skip to content

Commit 2468916

Browse files
IE8
1 parent e39db4b commit 2468916

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

json2.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
json2.js
3-
2013-05-26
3+
2014-02-04
44
55
Public Domain.
66
@@ -192,19 +192,11 @@ if (typeof JSON !== 'object') {
192192
};
193193
}
194194

195-
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
196-
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
195+
var cx,
196+
escapable,
197197
gap,
198198
indent,
199-
meta = { // table of character substitutions
200-
'\b': '\\b',
201-
'\t': '\\t',
202-
'\n': '\\n',
203-
'\f': '\\f',
204-
'\r': '\\r',
205-
'"' : '\\"',
206-
'\\': '\\\\'
207-
},
199+
meta,
208200
rep;
209201

210202

@@ -356,6 +348,16 @@ if (typeof JSON !== 'object') {
356348
// If the JSON object does not yet have a stringify method, give it one.
357349

358350
if (typeof JSON.stringify !== 'function') {
351+
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
352+
meta = { // table of character substitutions
353+
'\b': '\\b',
354+
'\t': '\\t',
355+
'\n': '\\n',
356+
'\f': '\\f',
357+
'\r': '\\r',
358+
'"' : '\\"',
359+
'\\': '\\\\'
360+
};
359361
JSON.stringify = function (value, replacer, space) {
360362

361363
// The stringify method takes a value and an optional replacer, and an optional
@@ -403,6 +405,7 @@ if (typeof JSON !== 'object') {
403405
// If the JSON object does not yet have a parse method, give it one.
404406

405407
if (typeof JSON.parse !== 'function') {
408+
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
406409
JSON.parse = function (text, reviver) {
407410

408411
// The parse method takes a text and an optional reviver function, and returns

0 commit comments

Comments
 (0)