]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/json.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo._base.json"]){
9 dojo
._hasResource
["dojo._base.json"]=true;
10 dojo
.provide("dojo._base.json");
11 dojo
.fromJson=function(_1
){
12 return eval("("+_1
+")");
14 dojo
._escapeString=function(_2
){
15 return ("\""+_2
.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
17 dojo
.toJsonIndentStr
="\t";
18 dojo
.toJson=function(it
,_3
,_4
){
23 if(_5
=="number"||_5
=="boolean"){
29 if(dojo
.isString(it
)){
30 return dojo
._escapeString(it
);
32 var _6
=arguments
.callee
;
35 var _8
=_3
?_4
+dojo
.toJsonIndentStr
:"";
36 var tf
=it
.__json__
||it
.json
;
37 if(dojo
.isFunction(tf
)){
43 if(it
.nodeType
&&it
.cloneNode
){
44 throw new Error("Can't serialize DOM nodes");
49 var _b
=dojo
.map(it
,function(_c
){
51 if(typeof _d
!="string"){
56 return "["+_b
.join(","+_9
)+_a
+_4
+"]";
64 if(typeof _f
=="number"){
67 if(typeof _f
=="string"){
68 _10
=dojo
._escapeString(_f
);
74 if(typeof val
!="string"){
77 _e
.push(_a
+_8
+_10
+":"+_9
+val
);
79 return "{"+_e
.join(","+_9
)+_a
+_4
+"}";