function ajaxGetMenuList(){ $.getJSON("login.do", function(json){ var r = ""; zNodes += "["; $(json.menuList).each(function(i){ r = json.menuList[i]; if(i>0) zNodes += ","; zNodes += '{'; zNodes += 'id:'+r.SId; zNodes += ', pId:'+r.SPid; zNodes += ', name:"'+r.STitle; if(r.SPid == 0) zNodes += '", open:true'; else zNodes += '"'; zNodes += '}'; }) zNodes += "]"; zNodes = stringToJSON(zNodes); createTree(zNodes); }); } /** * json转String * @param {Object} obj * @memberOf {TypeName} * @return {TypeName} */ function jsonToString (obj){ var THIS = this; switch(typeof(obj)){ case 'string': return '"' + obj.replace(/(["\\])/g, '\\$1') + '"'; case 'array': return '[' + obj.map(THIS.jsonToString).join(',') + ']'; case 'object': if(obj instanceof Array){ var strArr = []; var len = obj.length; for(var i=0; i"; }