<script type = "text/javascript">/*** Expaida qualquer objeto JS como um formato json string* @param {object} _obj: objeto que precisa ser produzido como string*/var obj2String = function (_obj) {var t = typeof (_obj); if (t! = 'objeto' || _obj === null) {// tipo de dados simples if (t == 'string') {_obj = '"' + _obj + '"'; } retornar string (_obj); } else {if (_obj instanceof date) {return _obj.tolocalestring (); } // Recurse matriz ou objeto var n, v, json = [], arr = (_obj && _obj.constructor == Array); para (n em _obj) {v = _obj [n]; t = typeof (v); if (t == 'string') {v = '"' + v + '"'; } else if (t == "object" && v! == null) {v = this.obj2String (v); } json.push ((arr? '': '"' + n + '":') + string (v)); } return (arr? '[': '{') + string (json) + (arr? ']': '}'); }}; var obj = {"resultado": {"fs": {"tsp.ibs.mirror": [{"_value": "1.0", "_class": 4}], "tsp.ibs.get.get_fnames": [{"_value": "0,0", "_cllass" 4}: ": "_value": "0.0", "_class": 4}], "tsp.ibr.info": [{"_value": "0.0", "_class": 4}]}}, "iscanceled": "false," ":", "isoSPONSED": " 0, "reqUID" : "xxxx-xxxxxxx-xxxxx-6c2f17bb-ea18-42ec-98fa-3f63b8d26aba-nd-rq", "version" : "1.0", "fName" : "TSP.IBR.GET_FNAMES", "message" : "4 functions were successfully obtained", "dir" : "DOWN", "NodeTime": 1362462128706, "iskeyCompressed": false, "seq": 2} alerta (obj2string (obj)) </sCript>