Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jq: update page #14841

Merged
merged 22 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pages/common/jq.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
> A JSON processor that uses a domain-specific language (DSL).
> More information: <https://jqlang.github.io/jq/manual/>.

- Execute a specific expression (print a colored and formatted JSON output):

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we shouldn't have a redundant example just to show the file input, although it is useful. I'll see what the other reviewers say. Related #13668

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one or the first example needs to delete, it is basically the same, just different way of stdin controller.

Copy link
Member

@sebastiaanspeck sebastiaanspeck Nov 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep the second example. The cat-page should show us that this is possible. Not in a non-related page. If someone never views jq, they will never know. It is more likely they will view cat, and then see the | example.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly either way. @vanvuvuong maybe keep the second example and we can get it merged and fix it later if it needs to be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


`jq '.' {{/path/to/file.json}}`
Expand All @@ -19,9 +15,9 @@

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

- Print specific keys:
- Create new JSON object via old JSON objects from multiple files:

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

- Print specific array items:

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

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

- Print objects with 2-condition filter 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", ...}}}'`