Binary Sludge
Easy CLI JSON Formatting
Command line JSON interpretation can be confusing. Python’s json library (2.6+) provides a simple prettifier:
$ echo '{"json":"obj"}' | python -mjson.tool
{
"json": "obj"
}
Or facetiously (from the obligatory Internet Chuck Norris Database):
$ curl -s "http://api.icndb.com/jokes/random?firstName=Andrew&lastName=Martin" | python -mjson.tool
{
"type": "success",
"value": {
"categories": [
"nerdy",
"chuck norris"
],
"id": 528,
"joke": "Andrew Martin doesn't use GUI, he prefers COMMAND line."
}
}
This can be wrapped in a handy shell function:
$ function parse_url_json()
{
curl -s "$@" | python -mjson.tool
}
$ parse_url_json 'http://api.icndb.com/jokes/random?firstName=Andrew&lastName=Martin'
2.5 users can install the simplejson library.
-
exhuma
-
http://lucumr.pocoo.org/ Armin Ronacher
-
http://www.dmuth.org/ Douglas Muth
-
sitaktif
-
http://www.binarysludge.com Andy
-
exhuma
-
wjoojoo
-
http://www.dasickis.com/ dasickis
-
NorthIsUp
-
http://www.dmuth.org/ Douglas Muth
Recent Posts
- Travis CI Chef Cookbooks
- The network is reliable
- Jeremy Ashkenas – Taking JavaScript Seriously with Backbone.js
- Signs that you’re a good programmer
- Signs that you’re a bad programmer
- How to Test Software (or: Teach Yourself to be a QA)
- Know Your Onions (and Antipatterns)
- Clean Code and Clean TDD Cheat Sheets
- The Definitive Guide to Bash Command Line History
- The analogy of print and code reviews
Archives
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- October 2010
- April 2010
- March 2010
Pages
Recent Comments





