mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-08-16 22:35:44 +02:00
jq: clarify descriptions (#1361)
This commit is contained in:
parent
776fdcf77a
commit
7ca686634d
1 changed files with 8 additions and 8 deletions
|
@ -2,26 +2,26 @@
|
||||||
|
|
||||||
> A lightweight and flexible command-line JSON processor.
|
> A lightweight and flexible command-line JSON processor.
|
||||||
|
|
||||||
- Output JSON file:
|
- Output a JSON file, in pretty-print format:
|
||||||
|
|
||||||
`cat {{file}} | jq`
|
`cat {{file}} | jq`
|
||||||
|
|
||||||
- Output all elements from JSON array in file, or all key-value pairs from JSON objects in file:
|
- Output all elements from arrays (or all key-value pairs from objects) in a JSON file:
|
||||||
|
|
||||||
`cat {{file}} | jq .[]`
|
`cat {{file}} | jq .[]`
|
||||||
|
|
||||||
- Read JSON objects from file, into array, and output (inverse of `jq .[]`):
|
- Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):
|
||||||
|
|
||||||
`cat {{file}} | jq --slurp`
|
`cat {{file}} | jq --slurp`
|
||||||
|
|
||||||
- Output first element in JSON file:
|
- Output the first element in a JSON file:
|
||||||
|
|
||||||
`cat {{file}} | jq .[0]`
|
`cat {{file}} | jq .[0]`
|
||||||
|
|
||||||
- Output "key" of first element in JSON file:
|
- Output the value of a given key of the first element in a JSON file:
|
||||||
|
|
||||||
`cat {{file}} | jq .[0].{{key}}`
|
`cat {{file}} | jq .[0].{{key_name}}`
|
||||||
|
|
||||||
- Output "key" of each element in JSON file:
|
- Output the value of a given key of each element in a JSON file:
|
||||||
|
|
||||||
`cat {{file}} | jq 'map(.{{key}})'`
|
`cat {{file}} | jq 'map(.{{key_name}})'`
|
||||||
|
|
Loading…
Add table
Reference in a new issue