I have a HTML5 application built using Twitter Bootstrap and JQuery (core).
It is a test/demo front-end for a REST-based service API.
In this application, I would like to show the JSON being received. On the page, that is. Not the console.
I would like to format the JSON (pretty-print) to be a bit more HUMAN-readable.
Is there an easy way to do this using HTML, JavaScript, and CSS? Is there a component I can use?
In addition, but not so important, I would like to give the user the ability to enter the JSON that makes up the request body. Is there a way that I can validate the JSON on the fly. Again, using HTML, CSS, and JavaScript?
Update: This question is a duplicate, and can be closed. It has been answered elsewhere - I should be using JSON.parse()
followed by JSON.stringify(...)
- stringify()
works on JSON objects, not JSON text strings, hence the need to parse()
first