by llimllib · 6y ago · 0 comments
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 notWhen 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.
From a teaching perspective it is probably best to start with the long-form.