OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 goog.provide('cvox.ChromeVoxJSON'); | 5 goog.provide('cvox.ChromeVoxJSON'); |
6 | 6 |
7 | 7 |
8 /** | 8 /** |
9 * @fileoverview A simple wrapper around the JSON APIs. | 9 * @fileoverview A simple wrapper around the JSON APIs. |
10 * If it is possible to use the browser's built in native JSON, then | 10 * If it is possible to use the browser's built in native JSON, then |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 return isFinite(this.valueOf()) ? | 49 return isFinite(this.valueOf()) ? |
50 this.getUTCFullYear() + '-' + | 50 this.getUTCFullYear() + '-' + |
51 f(this.getUTCMonth() + 1) + '-' + | 51 f(this.getUTCMonth() + 1) + '-' + |
52 f(this.getUTCDate()) + 'T' + | 52 f(this.getUTCDate()) + 'T' + |
53 f(this.getUTCHours()) + ':' + | 53 f(this.getUTCHours()) + ':' + |
54 f(this.getUTCMinutes()) + ':' + | 54 f(this.getUTCMinutes()) + ':' + |
55 f(this.getUTCSeconds()) + 'Z' : 'null'; | 55 f(this.getUTCSeconds()) + 'Z' : 'null'; |
56 }; | 56 }; |
57 | 57 |
58 String.prototype.toJSON = | 58 Boolean.prototype.toJSON = |
59 Number.prototype.toJSON = | 59 Number.prototype.toJSON = |
60 Boolean.prototype.toJSON = function(key) { | 60 String.prototype.toJSON = function(key) { |
61 return /** @type {string} */ (this.valueOf()); | 61 return /** @type {string} */ (this.valueOf()); |
62 }; | 62 }; |
63 } | 63 } |
64 | 64 |
65 var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u
202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, | 65 var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u
202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
66 escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b
5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, | 66 escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b
5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
67 gap, | 67 gap, |
68 indent, | 68 indent, |
69 meta = { // table of character substitutions | 69 meta = { // table of character substitutions |
70 '\b': '\\b', | 70 '\b': '\\b', |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return typeof reviver === 'function' ? walk({'': j}, '') : j; | 359 return typeof reviver === 'function' ? walk({'': j}, '') : j; |
360 } | 360 } |
361 | 361 |
362 // If the text is not JSON parseable, then a SyntaxError is thrown. | 362 // If the text is not JSON parseable, then a SyntaxError is thrown. |
363 | 363 |
364 throw new SyntaxError('JSON.parse'); | 364 throw new SyntaxError('JSON.parse'); |
365 }; | 365 }; |
366 } | 366 } |
367 }()); | 367 }()); |
368 } | 368 } |
OLD | NEW |