Tired of teaching your non-IT colleagues how to see what they got as a result from the API? Or are you yourself tired of opening the console?
Try displaying them in HTML using “Renderjson”.
The code renders the JSON lazily, only building the HTML when the user reveals the JSON by clicking the disclosure icons. This makes it extremely fast to do the initial render of huge JSON objects, since the only thing that renders initially is a single disclosure icon.
npm i renderjson
Just call the library in whatever way/tech you are using and then append the result of the JSON data passed on to renderjson() function. It takes in the JSON you want to render as a single argument and returns an HTML element.
Call set_show_to_level() to show different amounts of the JSON by default. The default is 0, and 1 is a popular choice. As a special case, if level is the string "all" then all the JSON will be shown by default. This, of course, removes the benefit of the lazy rendering, so it may be slow with large JSON objects.
Other options are discussed in the plugin page: https://www.npmjs.com/package/renderjson#options
References used are from the plugin’s official website: https://github.com/caldwell/renderjson
Top comments (0)