| 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 /** | 5 /** |
| 6 * Get the |key| attribute in the given |dict| and verify that it is an | 6 * Get the |key| attribute in the given |dict| and verify that it is an |
| 7 * array value. | 7 * array value. |
| 8 * | 8 * |
| 9 * If the attribute is not an array, then an exception will be thrown unless | 9 * If the attribute is not an array, then an exception will be thrown unless |
| 10 * a default value is specified in |opt_default|. | 10 * a default value is specified in |opt_default|. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 /** | 130 /** |
| 131 * Return a JSON object parsed from a string. | 131 * Return a JSON object parsed from a string. |
| 132 * | 132 * |
| 133 * If the string cannot be parsed, or does not result in an object, then an | 133 * If the string cannot be parsed, or does not result in an object, then an |
| 134 * exception will be thrown. | 134 * exception will be thrown. |
| 135 * | 135 * |
| 136 * @param {string} jsonString The JSON string to parse. | 136 * @param {string} jsonString The JSON string to parse. |
| 137 * @return {Object} The JSON object created from the |jsonString|. | 137 * @return {Object} The JSON object created from the |jsonString|. |
| 138 */ | 138 */ |
| 139 function getJsonObjectFromString(jsonString) { | 139 function getJsonObjectFromString(jsonString) { |
| 140 var value = /** @type {Object} */ JSON.parse(jsonString); | 140 var value = base.jsonParseSafe(jsonString); |
| 141 if (typeof value != 'object') { | 141 if (typeof value != 'object') { |
| 142 throw 'Invalid data type (expected: Object, actual: ' + typeof value + ')'; | 142 throw 'Invalid data type (expected: Object, actual: ' + typeof value + ')'; |
| 143 } | 143 } |
| 144 return value; | 144 return value; |
| 145 } | 145 } |
| OLD | NEW |