When working with RESTful services and JSON, there are several utilities which will make it easier to work with this format.
JSON Quick Look Plug-in
Since a blob of JSON data is just text, it can be saved into a simple, flat file. Amazingly enough, though, OS X does not have a native Quick Look plug-in to quickly preview files which end with the
json extension. Fortunately, third-party extensions are available, such as the quick look JSON plug-in from sagtau.com2. Installing the Quick Look plug-in can be performed in three quick steps.
- Download QuickLookJSON.qlgenerator
- Copy the file to the directory
- Restart the Quick Look Server with the Terminal command:
Text Filter Plug-Ins
BareBones Software makes two great text editors for the Mac, BBEdit and its little sister, TextWrangler. Both can also be extended with text filters which can be written in a variety of scripting languages like Perl, Python, or even a shell script. Text Filters are located in the following directories:
~/Library/Application Support/TextWrangler/Text Filters/
~/Library/Application Support/BBEdit/Text Filters/
After receiving an unorganized blob of JSON data from a web service, it would be nice to neatly format the information to make it easier to read for human consumption. An entry at Interactive Logic's1 site details how to create a Python scripts to take an unmanageable blob of JSON data and format it into a neater blob of JSON data.
Perhaps you don't like your JSON to be all nice and orderly and prefer a compressed mass of bits. No problem, there is a script for that, as well.
After a little research 3 through Python's documentation, I found that I could easily modify the
Format JSON.py file to strip out the unwanted white space from the formatted JSON.
- How to Format JSON in TextWrangler
- quick look JSON
- JSON encoder and decoder Python documentation
- Compact JSON Gist
- Format JSON Gist