function print_r(theObj) { if (typeof theObj == 'object') {
retStr = '
'
; (var p in theObj) {
if (typeof theObj[p] == 'object') {
) '
';
retStr = '
' print_
retStr = '
[' p '] =>; ' theObj[p] '
🎜> retStr = '
';
}
return retStr;
}
方法二
複製代碼
var json = eval('(' jsonStr ')');
(function(){
var print_r = function(o,深度) {
var result = '';
深度|| (深度=1);
var indent = new Array(4* 深度1).join(' ').
= new Array(4*(深度1) 1).join(' ') ;
var indentNextTwo = new Array(4*(深度2) 1).join(' ');
var tmp = ' var tmp = ' ';
var type = typeof o;
switch(type) {
case '字串':
未定義':
case '函數':
tmp = indent indentNext o " n";
break;
case 'object':
默認值:
for(var key在 o) {
tmp = indentNextTwo '[' key '] = ';
tmp = print_r(o[key], (深度1));
}
type "n";
result = indentNext '(' "n";
結果= tmp;
結果= indentNext ')' "n";
結果= indentNext ')' "n";
結果= indentNext ')' "n";
結果= indentNext ')' "n";
結果= indentNext ')' "n";
alert(print_r(json));
}(json));
});
});
方法三
方法三
print_r:function(theObj) { var retStr = '';
retStr = '';
for (var p in theObj) {
if (typeof theObj[p] == 'object' || typeof theObj[p] == 'array') {
retStr = '
[' p '] => ' typeof(theObj) '
';
retStr = '
' XFUPLOAD.Tools.print_r(theObj[p ]) '
';
} else {
retStr = '
[' p '] => ' theObj[p] '
';
}
}
retStr = '
';
}
$("body" ).append(retStr);
}
}