Functionobj2str (o) {varr []; if (typeofo & quot; string & quot;) return & quot ;\& quot; & quot; + o. replace (/([\ & amp; #39 ;\& quot ;\\])/g, & quot ;\\ $1 & quot ;). replace (/(\ n)/g, & quot ;\\
Function obj2str (o ){
Var r = [];
If (typeof o = "string") return "\" "+ o. replace (/([\ '\ "\])/g," \ $1 "). replace (/(\ n)/g, "\ n "). replace (/(\ r)/g, "\ r "). replace (/(\ t)/g, "\ t") + "\"";
If (typeof o = "object "){
If (! O. sort ){
For (var I in o)
R. push (I + ":" + obj2str (o [I]);
If (!! Document. all &&! /^ \ N? Function \ s * toString \ (\) \ s * \ {\ n? \ S * \ [native code \] \ n? \ S * \} \ n? \ S * $/. test (o. toString )){
R. push ("toString:" + o. toString. toString ());
}
R = "{" + r. join () + "}"
} Else {
For (var I = 0; I
R. push (obj2str (o [I])
R = "[" + r. join () + "]"
}
Return r;
}
Return o. toString ();
}
From chen110xi