/ Published in: JavaScript
Print json object in JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var s=''; //-------------------- function get_obj(objel, deep) { var s3= new Array(deep*3).join(' '); for (var el in objel) { s3+=typeof(objel[el])+' : '+el+' = ' if (typeof(objel[el])=='object') s3+=String.fromCharCode(13)+String.fromCharCode(10)+ get_obj(objel[el], deep+1); else { s3+= objel[el]+String.fromCharCode(13)+String.fromCharCode(10); } } return s3; } //-------------------- s=get_obj(inf,0);