2 ms·
╰─$ echo '[{"k1": "v1", "k2": "v2"}, {"k1": "v3"}]' | jq -r '.[] | .k1' v1 v3 https://codefaster.substack.com/p/mastering-jq-part-1-59c https://codefaster.
by d0mine 5y ago
╰─$ echo '[{"k1": "v1", "k2": "v2"}, {"k1": "v3"}]' | jq -r '.[] | .k1'
v1
v3
https://codefaster.substack.com/p/mastering-jq-part-1-59c https://codefaster.substack.com/p/mastering-jq-part-1-59c
1. parse a json value from stdin and set it as the initial result
2. for each function, apply the function to the result, and set the output as the result for the next function.
3. The final result is pretty printed on stdout.