← 返回命令列表

Linux command

jaq 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Filter JSON

echo '{"name": "world"}' | jaq '.name'

Process a JSON file

jaq '.[0]' [path/to/file.json]

Filter and format output

jaq -r '.[] | .name' [path/to/file.json]

Read YAML input

jaq --from yaml '.' [path/to/file.yaml]

Convert JSON to YAML

jaq --to yaml '.' [path/to/file.json]

说明

jaq is a clone of the JSON processing tool jq, focused on correctness, speed, and simplicity. It is available as both a command-line program (a near drop-in replacement for jq) and as a Rust library. Beyond standard JSON, jaq supports YAML, CBOR, TOML, and XML formats. jaq aims to provide more correct and predictable behavior than jq in edge cases, while maintaining compatibility for common usage. Its core has been security-audited by Radically Open Security.

参数

-r, --raw-output
Print strings without JSON quoting.
-R, --raw-input
Read input as raw strings, one per line.
-s, --slurp
Collect all input values into a single array.
-c, --compact-output
Emit JSON on a single line.
-S, --sort-keys
Sort object keys in the output.
--indent _N_
Use _N_ spaces per indent level (default 2).
--tab
Use a tab for each indent level.
-C, --color-output
Force colored output even when stdout is not a TTY.
-M, --monochrome-output
Disable colored output.
-i, --in-place
Rewrite each input file with the result of the filter.
--from _FORMAT_
Input format: json, yaml, cbor, toml, xml, csv, tsv, raw, raw0, xjon.
--to _FORMAT_
Output format (same set as --from).
-n, --null-input
Use null as the input value.

FAQ

What is the jaq command used for?

jaq is a clone of the JSON processing tool jq, focused on correctness, speed, and simplicity. It is available as both a command-line program (a near drop-in replacement for jq) and as a Rust library. Beyond standard JSON, jaq supports YAML, CBOR, TOML, and XML formats. jaq aims to provide more correct and predictable behavior than jq in edge cases, while maintaining compatibility for common usage. Its core has been security-audited by Radically Open Security.

How do I run a basic jaq example?

Run `echo '{"name": "world"}' | jaq '.name'` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -r, --raw-output do in jaq?

Print strings without JSON quoting.