mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-07-31 06:15:34 +02:00
jq: Add example for constructing new JSON object (#4172)
Co-authored-by: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
This commit is contained in:
parent
0a4e1cc43e
commit
fc69d1297d
1 changed files with 4 additions and 0 deletions
|
@ -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'`
|
||||
|
|
Loading…
Add table
Reference in a new issue