js Object2String方便查看js对象内容
<scripttype="text/javascript">
/**
*将JS的任意对象输出为json格式字符串
*@param{Object}_obj:需要输出为string的对象
*/
varobj2String=function(_obj){
vart=typeof(_obj);
if(t!='object'||_obj===null){
//simpledatatype
if(t=='string'){
_obj='"'+_obj+'"';
}
returnString(_obj);
}else{
if(_objinstanceofDate){
return_obj.toLocaleString();
}
//recursearrayorobject
varn,v,json=[],arr=(_obj&&_obj.constructor==Array);
for(nin_obj){
v=_obj[n];
t=typeof(v);
if(t=='string'){
v='"'+v+'"';
}elseif(t=="object"&&v!==null){
v=this.obj2String(v);
}
json.push((arr?'':'"'+n+'":')+String(v));
}
return(arr?'[':'{')+String(json)+(arr?']':'}');
}
};
varobj={
"result":{
"fs":{
"TSP.IBR.MIRROR":[{
"_value":"1.0",
"_class":4
}],
"TSP.IBR.GET_FNAMES":[{
"_value":"0.0",
"_class":4
}],
"TSP.IBR.GET_TOKEN_ID":[{
"_value":"0.0",
"_class":4
}],
"TSP.IBR.INFO":[{
"_value":"0.0",
"_class":4
}]
}
},
"isCanceled":false,
"e":"",
"isResponsed":true,
"aoqSize":0,
"isAsyncPost":false,
"code":0,
"reqUID":"xxxx-xxxxxx-xxxxx-6c2f17bb-ea18-42ec-98fa-3f63b8d26aba-nd-rq",
"version":"1.0",
"fName":"TSP.IBR.GET_FNAMES",
"message":"成功获取4个功能",
"dir":"DOWN",
"nodeTime":1362462128706,
"isKeyCompressed":false,
"seq":2
}
alert(obj2String(obj))
</script>热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短