Linux command
yj 命令
文件
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Example
cat [file.yaml] | yj
Example
cat [file.yaml] | yj -yt
Example
cat [file.json] | yj -jy
Example
cat [file.toml] | yj -ti
Example
cat [file.hcl] | yj -c
Example
cat [file.json] | yj -jti
说明
yj is a lightweight command-line tool for converting between YAML, JSON, TOML, and HCL serialization formats. It reads from stdin and writes to stdout, making it easy to compose with other Unix tools via piping. A key feature of yj is that it preserves map key order during conversion, which many similar tools do not. The default behavior converts YAML to JSON. Conversion direction is specified by combining format letters: the first letter is the input format and the second is the output format (e.g. -yt for YAML to TOML). Supported format versions are YAML v1.2, TOML v1.0.0, JSON RFC 7159, and HCL v1.
参数
- -yj, -y
- Convert YAML to JSON (default)
- -yy
- Convert YAML to YAML
- -yt
- Convert YAML to TOML
- -yc
- Convert YAML to HCL
- -jy, -r
- Convert JSON to YAML
- -jj
- Convert JSON to JSON
- -jt
- Convert JSON to TOML
- -jc
- Convert JSON to HCL
- -tj, -t
- Convert TOML to JSON
- -ty
- Convert TOML to YAML
- -tt
- Convert TOML to TOML
- -tc
- Convert TOML to HCL
- -cj, -c
- Convert HCL to JSON
- -cy
- Convert HCL to YAML
- -ct
- Convert HCL to TOML
- -cc
- Convert HCL to HCL
- -n
- Do not convert inf, -inf, and NaN to/from strings (YAML or TOML only)
- -e
- Escape HTML characters in output (JSON only)
- -i
- Indent output (JSON or TOML only)
- -k
- Attempt to parse keys as objects or numeric types (YAML output only)
- -h
- Show help
- -v
- Show version
FAQ
What is the yj command used for?
yj is a lightweight command-line tool for converting between YAML, JSON, TOML, and HCL serialization formats. It reads from stdin and writes to stdout, making it easy to compose with other Unix tools via piping. A key feature of yj is that it preserves map key order during conversion, which many similar tools do not. The default behavior converts YAML to JSON. Conversion direction is specified by combining format letters: the first letter is the input format and the second is the output format (e.g. -yt for YAML to TOML). Supported format versions are YAML v1.2, TOML v1.0.0, JSON RFC 7159, and HCL v1.
How do I run a basic yj example?
Run `cat [file.yaml] | yj` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -yj, -y do in yj?
Convert YAML to JSON (default)