News for hackers. Stuff that matters.
Re:Mastering Jq: Part 1 by llimllib on Tuesday June 30, 2020 @08:47PM (#23696533)
This example is weirdly spelled:

    echo '{"k1": [{"k2": [9]}]}' | jq '.k1 | .[0] | .k2 | .[0]'
is equivalent to

    echo '{"k1": [{"k2": [9]}]}' | jq '.k1[0].k2[0]'

I kept waiting for the author to explain this, but they did not
Re:Mastering Jq: Part 1 by code-faster on Wednesday July 01, 2020 @04:43AM (#23699300)
It is a weird way to write it, I never use this notation for myself.

When teaching though, I'd rather make the it more visually explicit that jq commands are a sequence of filters. With the former notation, a | explicitly tells the reader that it's the end of one filter and the start of a new one, the latter is more implicit.

Re:Mastering Jq: Part 1 by llimllib on Wednesday July 01, 2020 @10:21AM (#23701617)
That's possible! I've never had to teach it, good point.
Re:Mastering Jq: Part 1 by encloser on Wednesday July 01, 2020 @09:12AM (#23700930)
When I first started using jq, all of the examples I was following used the short-form. It took me a while to figure out how to use the functions and do some advanced transforms because of this. Since this article is Part 1 of a series I suspect the author will cover this in a later article.

From a teaching perspective it is probably best to start with the long-form.

Re:Mastering Jq: Part 1 by llimllib on Wednesday July 01, 2020 @10:22AM (#23701635)
good point, I hadn't considered that idea.