Skip to content

Commit

Permalink
add more jq example & remove duplicated one
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvuvuong committed Nov 15, 2024
1 parent 357208a commit 210b295
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pages/common/jq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

> A JSON processor that uses a domain-specific language (DSL).
> More information: <https://jqlang.github.io/jq/manual/>.
> See also: `trdsql`
- Execute a specific expression (print a colored and formatted JSON output):

Expand All @@ -15,9 +16,9 @@

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

- Print selected specific keys as JSON object:
- Create new JSON object via an old JSON object:

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

- Print specific array items:

Expand All @@ -27,7 +28,7 @@

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

- Print conditional objects in array:
- Print multi-conditional objects in array:

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

Expand Down

0 comments on commit 210b295

Please sign in to comment.