1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-01 00:15:32 +02:00

jq: Add example for constructing new JSON object (#4172)

Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
This commit is contained in:
Matt Watson 2020-07-17 18:37:49 +01:00 committed by GitHub
parent 0a4e1cc43e
commit fc69d1297d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,10 @@
`cat {{file.json}} | jq 'map(.{{key_name}})'`
- Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys `key_name` and `other_key_name`):
`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'`