Stephen Dolan’s “jq” is a lightweight and flexible command-line JSON processor

jq” (presumably) stands for “JSON query processor”.

jq helps writing shell scripts processing JSON responses from e.g. RESTful application APIs like Jenkins, Atlassian JIRA, Atlassian Confluence, … – code making use of powerful means like XPath (…) or jq is supposedly far more readable than Python / Perl / … scripts slurping the JSON and processing it (w/o jq resp. XPath) – but there are also Python resp. Perl bindings for jq.

Hope and fear

A couple of weeks ago I had written a shell script querying a Jenkins server’s REST API “à la XML”. Now it looks a little straighter to query the API “à la JSON” and employ jq. But the critical question is, whether the (industrial) customer (I wrote the Jenkins utility for) will like the dependency on a utility like jq. My Jenkins utility might have to serve for quite a couple of years – but who can predict the future and availability of jq?

Update 2016-02-23: Meanwhile I built a shell script with a couple of simple jq queries accessing Jenkins CI. Looks rather impressive to me.

If you do XPath queries from shell scripts, you always have the option to rewrite the shell script as Python or Perl script. But what about JSON queries (…) in Python or Perl?

By default, jq pretty-prints JSON output.

$ jq . < … > …

This site uses Akismet to reduce spam. Learn how your comment data is processed.