Ask HN: Library to pretty print JSON?

2 points by x0ner ↗ HN
I feel like I am in Google Hell right now. Why is there not a readily available library that I could call to get a clean, pretty printing of my JSON return output within the browser.

The only thing I have stumbled across is: http://www.cerny-online.com/

While it seems to do what I want, it looks for too chunky and complicated just to get some formatted JSON. Call me lazy, but a good old git clone and a function call would be nice.

Is there some buried treasure out there somewhere or do I need to write my own?

6 comments

[ 2.9 ms ] story [ 17.7 ms ] thread
The Python standard library's "pprint" pretty-prints data structures...it might work for JSON, since it looks basically the same (though I've never tried).
http://code.google.com/p/jsonview/ for firefox.

https://chrome.google.com/extensions/detail/ddngkjbldiejbhei... for chrome.

There is also a website that does a decent job as well http://jsonviewer.stack.hu/

All very nice viewers mate.

Viewers yes, but I need something that takes the JSON returned from an AJAX call and gives me a nice view of it. So it needs to be something I can call through an API or locally.
i dont quite understand, the plugins allow you to view the resultant JSON from an ajax request. Sorry for misunderstanding.

The Firefox plugin states:

Normally when encountering a JSON document (content type "application/json"), Firefox simply prompts you to download the view. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.