Tag Archives: json

While I was playing around with CouchDB and cURL I pretty quickly missed a feature to indent the json output string. So after looking around in the Internet for a simple solution I hit simplejson which provides methods to indent a json string.

To be able to run the script simplejson needs to be installed. On a debian based system you can easily run following command to assure simplejson is installed:sudo apt-get install python-simplejson

How to use it

Let’s store the script to jsonindent.py in a executable path directory such as $HOME/bin (run echo $PATH to get more possible directories). To indent a json script returned for instance from a CouchDB you can easily use following command:curl -sX GET http://127.0.0.1:5984/example/hello-world | jsonindent.py