Changeset 13188
- Timestamp:
- 03/24/08 20:06:41 (8 months ago)
- Files:
-
- 1 modified
-
dojo/trunk/_base/json.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/_base/json.js
r12247 r13188 3 3 dojo.fromJson = function(/*String*/ json){ 4 4 // summary: 5 // evaluates the passed string-form of a JSON object5 // Parses a [JSON](http://json.org) string to return a JavaScript object. 6 6 // json: 7 7 // a string literal of a JSON item, for instance: 8 // '{ "foo": [ "bar", 1, { "baz": "thud" } ] }' 9 // return: 10 // An object, the result of the evaluation 8 // `'{ "foo": [ "bar", 1, { "baz": "thud" } ] }'` 11 9 12 return eval("(" + json + ")"); 10 return eval("(" + json + ")"); // Object 13 11 } 14 12 … … 26 24 dojo.toJson = function(/*Object*/ it, /*Boolean?*/ prettyPrint, /*String?*/ _indentStr){ 27 25 // summary: 28 // Create a JSON serialization of an object. 26 // Returns a [JSON](http://json.org) serialization of an object. 27 // 28 // description: 29 // Returns a [JSON](http://json.org) serialization of an object. 29 30 // Note that this doesn't check for infinite recursion, so don't do that! 30 31 // … … 43 44 // _indentStr: 44 45 // private variable for recursive calls when pretty printing, do not use. 45 //46 // return:47 // a String representing the serialized version of the passed object.48 46 49 47 if(it === undefined){ … … 109 107 */ 110 108 if(objtype == "function"){ 111 return null; 109 return null; // null 112 110 } 113 111 // generic object code path … … 132 130 output.push(newLine + nextIndent + keyStr + ":" + sep + val); 133 131 } 134 return "{" + output.join("," + sep) + newLine + _indentStr + "}"; 132 return "{" + output.join("," + sep) + newLine + _indentStr + "}"; // String 135 133 }