One of the features json.org mentions when describing JSON is that “It is easy for humans to read and write”. This is mostly true, however when you’re dealing with a large chunk of dynamically generated JSON it can be a little bit of a tougher ask for this human, especially if it’s in the context of an AJAX application where typically the JSON data will be lacking in formatting, indentation and white space in order to speed up transmission.
So here’s a couple of simple things we’ve found that help to make working with JSON slightly easier.
SublimeText – I really love working with SublimeText. Now, out of the box it comes with support for a lot of languages.. but not JSON. Never fear, as it supports Textmate .tmlanguage files, so you can add JSON support quite easily by downloading this .tmlanguage file and adding it to your Sublime Text\Packages directory. Restart SublimeText, and JSON highlighting can be yours.
However if your JSON is lacking in white space and carriage returns then even with the highlighting it’s not going to be too easy to read. Enter the next tool:
Simple JSON Formatter – this is a client side JSON formatter written in JavaScript by Jon Combe. Being paranoid at the thought of the Internet being down we’ve taken a copy and popped it on our own servers for our convenience. The JSON formatter will do exactly what its name implies – it lets you paste a chunk of unformatted JSON into the text box, then click the button, and have it formatted with white space, indentation, and carriage returns.
Combine these two simple tools together, and you’ve got a much improved JSON debugging experience!
-Ross
asd