jq: add filter array example (#7871)

* Add filter array example

* Remove 8th example
feature/russian-ed-update
Yorke Rhodes 2022-03-11 20:08:08 -08:00 committed by GitHub
parent 25070ff4e7
commit fc874d901b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -11,6 +11,10 @@
`jq '.[]' {{file.json}}`
- Output elements from arrays which match provided filter:
`jq '.[] | select(.{{key_name}} == {{value}})'`
- Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):
`jq --slurp . {{file.json}}`
@ -27,10 +31,6 @@
`cat {{file.json}} | jq '{{{my_new_key}}: .{{key_name}}, {{my_other_key}}: .{{other_key_name}}}'`
- Combine multiple filters:
`cat {{file.json}} | jq 'unique | sort | reverse'`
- Output the value of a given key to a string (and disable JSON output):
`cat {{file.json}} | jq --raw-output '"some text: \(.{{key_name}})"'`