← 返回命令列表

Linux command

json5 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Parse JSON5 to JSON

json5 [file.json5]

Convert from stdin

echo '{name: "test"}' | json5

Pretty print

json5 --space [2] [file.json5]

Validate only

json5 --validate [file.json5]

Indent with tabs

json5 --space t [file.json5]

Convert and write to file

json5 --out-file [output.json] [file.json5]

说明

json5 parses JSON5 format and outputs standard JSON. JSON5 extends JSON with comments, trailing commas, and unquoted keys. The tool converts more readable JSON5 configs to strict JSON. It validates and formats JSON5 input.

参数

-s, --space _N_
Number of spaces to indent, or "t" for tabs.
-v, --validate
Validate JSON5 syntax without outputting JSON.
-o, --out-file _FILE_
Write output to file instead of stdout.
-V, --version
Display version number.
-h, --help
Display help information.

FAQ

What is the json5 command used for?

json5 parses JSON5 format and outputs standard JSON. JSON5 extends JSON with comments, trailing commas, and unquoted keys. The tool converts more readable JSON5 configs to strict JSON. It validates and formats JSON5 input.

How do I run a basic json5 example?

Run `json5 [file.json5]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s, --space _N_ do in json5?

Number of spaces to indent, or "t" for tabs.