diff options
| author | Igor Minar | 2012-03-28 12:21:07 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-28 16:57:34 -0700 |
| commit | af0ad6561c0d75c4f155b07e9cfc36a983af55bd (patch) | |
| tree | 8d1ddb4747553cb79d43332025a757b31c47f67f /src/JSON.js | |
| parent | 35125d25137ac2da13ed1ca3e652ec8f2c945053 (diff) | |
| download | angular.js-af0ad6561c0d75c4f155b07e9cfc36a983af55bd.tar.bz2 | |
refactor(fromJson/toJson): move the contents of these files into Angular.js
these files are now mostly empty so it doesn't make sense to keep them
separated from other helper functions
Diffstat (limited to 'src/JSON.js')
| -rw-r--r-- | src/JSON.js | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/JSON.js b/src/JSON.js deleted file mode 100644 index e6d48c86..00000000 --- a/src/JSON.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -var jsonReplacer = function(key, value) { - var val = value; - if (/^\$+/.test(key)) { - val = undefined; - } else if (isWindow(value)) { - val = '$WINDOW'; - } else if (value && document === value) { - val = '$DOCUMENT'; - } else if (isScope(value)) { - val = '$SCOPE'; - } - - return val; -}; - -/** - * @ngdoc function - * @name angular.toJson - * @function - * - * @description - * Serializes input into a JSON-formatted string. - * - * @param {Object|Array|Date|string|number} obj Input to be serialized into JSON. - * @param {boolean=} pretty If set to true, the JSON output will contain newlines and whitespace. - * @returns {string} Jsonified string representing `obj`. - */ -function toJson(obj, pretty) { - return JSON.stringify(obj, jsonReplacer, pretty ? ' ' : null); -} - -/** - * @ngdoc function - * @name angular.fromJson - * @function - * - * @description - * Deserializes a JSON string. - * - * @param {string} json JSON string to deserialize. - * @returns {Object|Array|Date|string|number} Deserialized thingy. - */ -function fromJson(json) { - return isString(json) - ? JSON.parse(json) - : json; -} |
