Search code examples
htmljsondojoxmlhttprequest

Rendering JSON to HTML


just a quick question to hopefully get pointed in the right direction. I took over for another developer and I'm flying by the seat of my (now ripped LOL!) pants. I have a webpage that has the JSON included and I simply need to render it to HTML. Now for the gory details... I'm building a help page (using Catalyst/Template Toolkit and Dojo). I have succeeded far enough to build the page with the tabs and including the JSON chunk. YAY! for me (Really you have no idea how good I feel for being able to do just THAT!)
This is more of a question of where to go next and any pointers would be appreciated.
Is it best to get dojo to read the JSON and write it out to a div somehow? Any hint as to how I would go about that? When Googling "JSON to HTML" I get plenty of suggestions for third party products and I'm not that greatly familiar with DOJO yet and even less so with AJAX.
Any advice would be greatly appreciated... Janie


Solution

  • This page from the Dojo documentation might be helpful. It refers to the library's function dojo.fromJson to convert a string of JSON-formatted text to a JavaScript object. You could then access the properties of the object and insert them with HTML into a div tag.