mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 02:10:24 +00:00
toJson and fromJson jsdocs
This commit is contained in:
parent
dd687e2bf5
commit
d4bcee0799
1 changed files with 23 additions and 0 deletions
23
src/JSON.js
23
src/JSON.js
|
|
@ -1,11 +1,34 @@
|
|||
var array = [].constructor;
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name angular.toJson
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Serializes the input into a JSON formated string.
|
||||
*
|
||||
* @param {Object|Array|Date|string|number} obj Input to jsonify.
|
||||
* @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) {
|
||||
var buf = [];
|
||||
toJsonArray(buf, obj, pretty ? "\n " : _null, []);
|
||||
return buf.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name angular.fromJson
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Deserializes a string in the JSON format.
|
||||
*
|
||||
* @param {string} json JSON string to deserialize.
|
||||
* @returns {Object|Array|Date|string|number} Deserialized thingy.
|
||||
*/
|
||||
function fromJson(json) {
|
||||
if (!json) return json;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue