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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 gap = mind; | 220 gap = mind; |
221 return v; | 221 return v; |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 // If the JSON object does not yet have a stringify method, give it one. | 225 // If the JSON object does not yet have a stringify method, give it one. |
226 | 226 |
227 if (typeof cvox.ChromeVoxJSON.stringify !== 'function') { | 227 if (typeof cvox.ChromeVoxJSON.stringify !== 'function') { |
228 /** | 228 /** |
229 * @param {*} value Input object. | 229 * @param {*} value Input object. |
230 * @param {(Array.<string>|(function(string, *) : *)|null)=} replacer | 230 * @param {(Array<string>|(function(string, *) : *)|null)=} replacer |
231 * Replacer array or function. | 231 * Replacer array or function. |
232 * @param {(number|string|null)=} space Whitespace character. | 232 * @param {(number|string|null)=} space Whitespace character. |
233 * @return {string} json string which represents jsonObj. | 233 * @return {string} json string which represents jsonObj. |
234 */ | 234 */ |
235 cvox.ChromeVoxJSON.stringify = function(value, replacer, space) { | 235 cvox.ChromeVoxJSON.stringify = function(value, replacer, space) { |
236 | 236 |
237 // The stringify method takes a value and an optional replacer, and an | 237 // The stringify method takes a value and an optional replacer, and an |
238 // optional space parameter, and returns a JSON text. The replacer can | 238 // optional space parameter, and returns a JSON text. The replacer can |
239 // be a function that can replace values, or an array of strings that | 239 // be a function that can replace values, or an array of strings that |
240 // will select the keys. A default replacer method can be provided. Use | 240 // will select the keys. A default replacer method can be provided. Use |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 return typeof reviver === 'function' ? walk({'': j}, '') : j; | 361 return typeof reviver === 'function' ? walk({'': j}, '') : j; |
362 } | 362 } |
363 | 363 |
364 // If the text is not JSON parseable, then a SyntaxError is thrown. | 364 // If the text is not JSON parseable, then a SyntaxError is thrown. |
365 | 365 |
366 throw new SyntaxError('JSON.parse'); | 366 throw new SyntaxError('JSON.parse'); |
367 }; | 367 }; |
368 } | 368 } |
369 }()); | 369 }()); |
370 } | 370 } |
OLD | NEW |