JSON Tree(1 function 15 lines)Nested Ul from single or multidimensional json object


/ Published in: JavaScript
Save to your folder(s)

Any valid json object will be recursively traversed building a nested unordered list of its properties and their values. This example parses the json entered in the text area into an object that is passed to the json_tree() function. I use the twitter bootstrap to make collapsible trees. That is the purpose of thee css and the random string i generate. I left it in as an example of how you might style the returned list. This is very much a work in progress so if you have any suggestions please post a comment. I have posted the entire html for a working example page just create the file and open it in your browser.(make sure your json validates - http://jsonlint.com - only valid json will produce a tree)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.