jq is awesome, a real achievement.<p>At the same time it demonstrates everything that is wrong with traditional shells and what PowerShell gets so right.<p>jq is <i>not</i> a "Unixy" tool in the sense that it should do one thing and do it right. jq implements its own expression language, command processor complete with internal "pipelines". Why would a tool need to do that? find is another utility that does many, many other things than to "find" items: It executes commands, deletes objects etc.<p>Consider this challenge that included parsing json, filtering, projecting and csv-formatting output: <a href="https://news.ycombinator.com/item?id=9438109" rel="nofollow">https://news.ycombinator.com/item?id=9438109</a><p>Several solutions uses jq - to good effect. But the PowerShell solution uses <i>PowerShell</i> expressions to filter, sort and project items.<p>The problem is - at the core - that the traditional command tools are severely restricted by only being able to rely on a text pipeline convention. You cannot parse json and send the "objects" along to another tool. Well, you can, if the json tree is extremely basic - like 2 levels.<p>PowerShell also has a json parser tool: <a href="https://technet.microsoft.com/en-us/library/hh849898.aspx" rel="nofollow">https://technet.microsoft.com/en-us/library/hh849898.aspx</a>. It is called ConvertFrom-Json (follows the verb-noun convention) and is distributed as part of PowerShell (built-in if you want - but that's a misnomer for PowerShell modules).<p>It is extremely simple - it doesn't even take any parameters - it just converts a string (parses it as json) and outputs the object/objects which can be arbitrarily complex. It truly does only one thing. If you want to select specific properties, sort, group etc you do it with other PS tools like select (alias for Select-Object), sort (alias for Sort-Object), group (alias for Group-Object) etc. If you want to convert back to json you use ConvertTo-Json.
I've been using this for a couple months now. With httpie[1], it's become as essential to my work day as Grep.<p>[1] <a href="https://github.com/jakubroztocil/httpie" rel="nofollow">https://github.com/jakubroztocil/httpie</a>
Love, <i>love</i> jq...after awhile, I realized I was twisting my brain too much to get bash to do what it wasn't meant to do, but I got a lot of mileage of just playing with APIs because of how jq made it so easy. I came up with some fun lessons on how to use jq and other CLI-tools to tour the Spotify API [1] and to mash up images from Instagram [2]<p>[1] <a href="http://www.compciv.org/recipes/data/touring-the-spotify-api/" rel="nofollow">http://www.compciv.org/recipes/data/touring-the-spotify-api/</a><p>[2] <a href="http://www.compciv.org/recipes/data/api-exploration-with-gmaps-instagram/" rel="nofollow">http://www.compciv.org/recipes/data/api-exploration-with-gma...</a><p>(note: while I say that I like the command-line, I'm not die-hard enough to have stopped to learn awk, so take that fwiw)
Using it for parsing AWS CLI responses, it's been a sweet tool to parse those JSON responses from AWS, most of the time I'd fire some python script to parse the data and now with jq I can keep most of the one-time scripts limited to bash only, if I need something more maintainable or longer living then I'll drop a script in python or ruby.
Lots of previous discussions about this on HN (for instance [0]) but still a sweet tool.<p>[0] <a href="https://news.ycombinator.com/item?id=5734683" rel="nofollow">https://news.ycombinator.com/item?id=5734683</a>
Jq is truly amazing swiss army knife for JSON viewing/processing in command line.<p>Btw, I've seen people posting this github link at least 10 times in the past. I thought HN filters dupes, what gives?<p><a href="https://hn.algolia.com/?query=http:%2F%2Fstedolan.github.io%2Fjq%2F&sort=byPopularity&prefix&page=0&dateRange=all&type=story" rel="nofollow">https://hn.algolia.com/?query=http:%2F%2Fstedolan.github.io%...</a>
For a similar tool written in javascript, check out json (<a href="https://github.com/trentm/json" rel="nofollow">https://github.com/trentm/json</a>). I use both.
I know it is right on the linked page, but it is useful enough I think it deserves a direct link in any conversation:<p><a href="https://jqplay.org/" rel="nofollow">https://jqplay.org/</a>
Compare: rl_json -- Extends Tcl with a json value type and a command to manipulate json values directly. The commands accept a path specification that names some subset of the supplied json entity. The paths used by [json] allow indexing into JSON arrays by the integer key.<p><a href="https://github.com/RubyLane/rl_json" rel="nofollow">https://github.com/RubyLane/rl_json</a>
For those on OS X, check out JSON Query: <a href="https://itunes.apple.com/us/app/json-query/id953006734?mt=12" rel="nofollow">https://itunes.apple.com/us/app/json-query/id953006734?mt=12</a><p>It's not nearly as powerful as jq, but for simple querying and downloading JSON (with POST body and HTTP headers), I find it quite useful.<p>Disclaimer: I built it.
I recently had to consume an xml service; it would've been great to have something like Jq for xml. For some reason I wasn't really interested in xml -> json conversion as a first step. I also found a bunch of xml cli tools, but they are older, had to learn things like XQuery (which actually few tools today seem to support).
Nice. I made jipe[0] a while back to handle common troubleshooting tasks with streams of json objects. I still use it quite a bit. I didn't see anything about streaming in the jq docs.<p>[0] <a href="https://github.com/dokipen/jipe" rel="nofollow">https://github.com/dokipen/jipe</a>
We are using jq to parse JSON output from various API in shell scripts. It served us well even for large JSON strings. If you want to write small scripts and parse some JSON in it then jq is best fit.
i love it so much.<p>i've used it for things like migrating between json schemas, and even converting normal json into elasticsearch bulk imports on the fly.
I appreciate jq and use it almost every day. At the same time, I recently had a task that was easier to do in Node.js. I had a file containing a JSON object with a structure like so: [ { }, { }, ... ] and I wanted to turn each object into a separate file.
Looks interesting. Given this json,
[{"name":"john", "grades":[1,2,3]}, {"name":"jane", "grades":[4,5,6]}],
can it print it out as this:
john,1
john,2
john,3
jane,4
jane,5
jane,6