Im using ajax to query a json api. It gives me a Tree like structure, which I'd like to visualize. A sample response looks like
{
"nicos": {
"_lastconfig_": {
"poller": {
"alwayspoll": [],
"blacklist": [],
"neverpoll": [
"detector"
]
}
},
"poller": {
"alwayspoll": [],
"autosetup": true,
"blacklist": [],
"description": "",
"loglevel": "info",
"lowlevel": false,
"neverpoll": [
"detector"
],
"poll": []
}
}
}
Now I'd like to parse this dynamically and visualize it as tables. A possible output could be
<h1>nicos</h1>
<h2>_last_config_</h2>
<table>
<tr><td>alwayspoll</td><td>[]</td></tr>
<tr><td>blacklist</td><td>[]</td></tr>
<tr><td>neverpoll</td><td>[detector]</td></tr>
</table>
<h2>poller</h2>
<table>
<tr><td>alwayspoll</td><td>[]</td></tr>
<tr><td>autosetup</td><td>true</td></tr>
<tr><td>blacklist</td><td>[]</td></tr>
<tr><td>description</td><td></td></tr>
<tr><td>loglevel</td><td>info</td></tr>
<tr><td>lowlevel</td><td>false</td></tr>
<tr><td>neverpoll</td><td>[detector]</td></tr>
<tr><td>poll</td><td>[]</td></tr>
</table>
Since I'm a complete novice in javascript I'm asking for some advice on how I could achive that. The ajax part is not the problem, but the parsing bothers me.
<ul>
though, as it is more of a list than tabular.<dl>
<dl>
and the new and awesomeHTML5
here: html5doctor.com/the-dl-element