ZEN component to display JSON data
Hello,
is there some kind ZEN component available (e.g. tree or anything), which can display raw JSON string data nicely on ZEN webpage ?
JSON string contains primary nodes, subnodes, arrays.
Discussion (2)0
Comments
Why not just cut and paste the JSON into http://jsbeautifier.org/
Hi Bapu,
There is a really simple solution, no Zen required.
Put some pre tags on your web page...
<pre id="json-preview-panel"></pre>
If your JSON is an object then...
document.getElementById("json-preview-panel").innerHTML=JSON.stringify(json, undefined, 2);
Note that the third argument in stringify() is the number of spaces to insert for prettifying.
If your JSON is a string already then you will need to convert it to an object and then back again...
document.getElementById("json-preview-panel").innerHTML=JSON.stringify(JSON.parse(json),undefined,2);
Sean.