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

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'`