Javascript: How to generate formatted easy-to-read JSON straight from an object?

0 Answers

json format

Possible Duplicate:
How can I beautify JSON programmatically?

I know how to generate JSON from an object using JSON.stringify, or in my case the handy jquery-json from google code (

Now this works fine, but the output is hard to read for humans. Is there an easy way / function / whatever to output a neatly formatted json file?

This is what I mean:




I'd like something like this instead:


E.g. with newlines and tabs added. It's much easier to read for larger documents.

I'd like to do this ideally without adding any huge libraries - e.g. not prototype or YUI or whatever.