Skip to content

Commit

Permalink
udpate jq page
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvuvuong committed Nov 15, 2024
1 parent 81739ca commit 357208a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pages/common/jq.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

`{{cat path/to/file.json}} | jq '.'`

- Execute a specific expression only using the `jq` binary (print a colored and formatted JSON output):

`jq '.' {{/path/to/file.json}}`

- Execute a specific script:

`{{cat path/to/file.json}} | jq --from-file {{path/to/script.jq}}`
Expand All @@ -19,9 +15,9 @@

`{{cat path/to/file.json}} | jq {{--arg "name1" "value1" --arg "name2" "value2" ...}} '{{. + $ARGS.named}}'`

- Print specific keys:
- Print selected specific keys as JSON object:

`{{cat path/to/file.json}} | jq '{{.key1, .key2, ...}}'`
`{{cat path/to/file.json}} | jq '{{{key1,key2, ...}}}'`

- Print specific array items:

Expand All @@ -31,6 +27,10 @@

`{{cat path/to/file.json}} | jq '.[]'`

- Print conditional objects in array:

`{{cat path/to/file.json}} | jq '.[] | select((.key1=="value1") and .key2=="value2")'`

- Add/remove specific keys:

`{{cat path/to/file.json}} | jq '. {{+|-}} {{{"key1": "value1", "key2": "value2", ...}}}'`

0 comments on commit 357208a

Please sign in to comment.