Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a simple library that will render JSON objects as trees?

So, is there a VERY simple library that will render JSON objects as trees? I know that this can be done in many ways (such as YUI), but for debug purposes I'd like to simply be able to view a JSON objects I receive from a server as a tree, nothing fancy (but collapsable tree's would be a bonus).

The kind of solution I'm looking for would be something like:

<script source="something.js"/>
<script>
   obj ={"hello":"world"}
   lib.renderJSON("someid",obj);
</script>
...    
<div id="someid"/>

Any ideas?

like image 474
Robert Gould Avatar asked Mar 13 '09 02:03

Robert Gould


3 Answers

check this too: http://jquery.bassistance.de/treeview/demo/async.html

like image 147
Amit Avatar answered Nov 14 '22 22:11

Amit


As this thread came up in response to a Google search, thought it might be worth adding in what I found (the other link no longer appears valid in this context, but I could have missed some functionality).

There are a few around, but I did not find one that provided it in a "graphical tree view", rather a simple "text tree view". There were titled as "beautifiers" or "easy read" JSON viewers.

I ended up using: jsonview by yesmeck

Nice and simple, and did the job first time.

like image 36
From Orbonia Avatar answered Nov 14 '22 22:11

From Orbonia


use D3 it is very easy to load json data just something like this

         d3.json("flare.json", function(error, flare) {
              flare.x0 = 0;
               flare.y0 = 0
               update(root = flare);
           });
like image 35
knives22 Avatar answered Nov 14 '22 22:11

knives22