Tuesday, April 19, 2016

JQ

Many modern web services give you data in JSON so that you can easily incorporate it into web applications. But a lot of automation tasks are done in the shell, where the built-in tools predate JSON and thus can't handle that particular structure.

Sound familiar? You should check out jq, a tool that interprets JSON data and gives you a language for extracting, reformatting, and manipulating it. It uses a data-flow metaphor analogous to awk where you work with chunks of data at a time.

Large percentages of my automation scripts now incorporate jq, and it sometimes seems like my main contribution at my current job was introducing it to the development toolkit.

2 comments:

  1. Wow... must be an amazing tool to break a 3 year hiatus! (j/k) Just think, the magic of RSS means my feed reader has been checking this blog 4 times an hour for 3 years waiting just for this moment! Amazingly, I happened to be insomniatic tonight so I happened to see it as well! Even more amazingly I installed node-json just today (yesterday?) after checking out jq and deciding all I really needed was pretty printing. What a nutty coincidences! So crazy!

    ReplyDelete
  2. Ha!

    I've been meaning to start up the blogging again just to keep my writing muscles limber (though writing at GeekDad helps with that a bit). I'll take a look at node-json, but I use jq's language constructs heavily for automating and reporting.

    ReplyDelete