日期:2014-05-16 浏览次数:20420 次
doEncode = function(o){ if(typeof o == "undefined" || o === null){ return "null"; }else if(Ext.isArray(o)){ return encodeArray(o); }else if(Object.prototype.toString.apply(o) === '[object Date]'){ return Ext.util.JSON.encodeDate(o); }else if(typeof o == "string"){ return encodeString(o); }else if(typeof o == "number"){ return isFinite(o) ? String(o) : "null"; }else if(typeof o == "boolean"){ return String(o); }else { var a = ["{"], b, i, v; for (i in o) { if(!useHasOwn || o.hasOwnProperty(i)) { v = o[i]; switch (typeof v) { case "undefined": case "function": case "unknown": break; default: if(b){ a.push(','); } a.push(doEncode(i), ":", v === null ? "null" : doEncode(v)); b = true; } } } a.push("}"); return a.join(""); } }
?Ext.util.JSON.decode?? Ext.decode???? json字符串解码成js对象,js中直接调eval方法就可以
Ext.util.JSON.encode?? Ext.encode???? js对象编码成json字符串,代码如下
?
?