|
1 | 1 | /*
|
2 |
| - json2.js |
3 |
| - 2011-08-30 |
| 2 | + http://www.JSON.org/json2.js |
| 3 | + 2011-10-19 |
4 | 4 |
|
5 | 5 | Public Domain.
|
6 | 6 |
|
|
146 | 146 | redistribute.
|
147 | 147 | */
|
148 | 148 |
|
149 |
| -/*jslint evil: true, regexp: true, unparam: true */ |
| 149 | +/*jslint evil: true, regexp: true */ |
150 | 150 |
|
151 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
152 | 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
@@ -176,13 +176,14 @@ if (!JSON) {
|
176 | 176 |
|
177 | 177 | Date.prototype.toJSON = function (key) {
|
178 | 178 |
|
179 |
| - return isFinite(this.valueOf()) ? |
180 |
| - this.getUTCFullYear() + '-' + |
181 |
| - f(this.getUTCMonth() + 1) + '-' + |
182 |
| - f(this.getUTCDate()) + 'T' + |
183 |
| - f(this.getUTCHours()) + ':' + |
184 |
| - f(this.getUTCMinutes()) + ':' + |
185 |
| - f(this.getUTCSeconds()) + 'Z' : null; |
| 179 | + return isFinite(this.valueOf()) |
| 180 | + ? this.getUTCFullYear() + '-' + |
| 181 | + f(this.getUTCMonth() + 1) + '-' + |
| 182 | + f(this.getUTCDate()) + 'T' + |
| 183 | + f(this.getUTCHours()) + ':' + |
| 184 | + f(this.getUTCMinutes()) + ':' + |
| 185 | + f(this.getUTCSeconds()) + 'Z' |
| 186 | + : null; |
186 | 187 | };
|
187 | 188 |
|
188 | 189 | String.prototype.toJSON =
|
@@ -218,8 +219,9 @@ if (!JSON) {
|
218 | 219 | escapable.lastIndex = 0;
|
219 | 220 | return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
220 | 221 | var c = meta[a];
|
221 |
| - return typeof c === 'string' ? c : |
222 |
| - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 222 | + return typeof c === 'string' |
| 223 | + ? c |
| 224 | + : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
223 | 225 | }) + '"' : '"' + string + '"';
|
224 | 226 | }
|
225 | 227 |
|
@@ -303,9 +305,11 @@ if (!JSON) {
|
303 | 305 | // Join all of the elements together, separated with commas, and wrap them in
|
304 | 306 | // brackets.
|
305 | 307 |
|
306 |
| - v = partial.length === 0 ? '[]' : gap ? |
307 |
| - '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : |
308 |
| - '[' + partial.join(',') + ']'; |
| 308 | + v = partial.length === 0 |
| 309 | + ? '[]' |
| 310 | + : gap |
| 311 | + ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' |
| 312 | + : '[' + partial.join(',') + ']'; |
309 | 313 | gap = mind;
|
310 | 314 | return v;
|
311 | 315 | }
|
@@ -340,9 +344,11 @@ if (!JSON) {
|
340 | 344 | // Join all of the member texts together, separated with commas,
|
341 | 345 | // and wrap them in braces.
|
342 | 346 |
|
343 |
| - v = partial.length === 0 ? '{}' : gap ? |
344 |
| - '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : |
345 |
| - '{' + partial.join(',') + '}'; |
| 347 | + v = partial.length === 0 |
| 348 | + ? '{}' |
| 349 | + : gap |
| 350 | + ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' |
| 351 | + : '{' + partial.join(',') + '}'; |
346 | 352 | gap = mind;
|
347 | 353 | return v;
|
348 | 354 | }
|
@@ -468,8 +474,9 @@ if (!JSON) {
|
468 | 474 | // In the optional fourth stage, we recursively walk the new structure, passing
|
469 | 475 | // each name/value pair to a reviver function for possible transformation.
|
470 | 476 |
|
471 |
| - return typeof reviver === 'function' ? |
472 |
| - walk({'': j}, '') : j; |
| 477 | + return typeof reviver === 'function' |
| 478 | + ? walk({'': j}, '') |
| 479 | + : j; |
473 | 480 | }
|
474 | 481 |
|
475 | 482 | // If the text is not JSON parseable, then a SyntaxError is thrown.
|
|
0 commit comments