Linux command
json_pp 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Pretty print JSON
json_pp < [data.json]
Format JSON file to output file
json_pp < [input.json] > [output.json]
Sort keys alphabetically
json_pp -json_opt canonical < [data.json]
Output as Perl Data::Dumper format
json_pp -t dumper < [data.json]
Use multiple formatting options
json_pp -json_opt pretty,canonical,utf8 < [data.json]
Validate JSON
json_pp -t null < [data.json]
说明
json_pp is a JSON::PP command utility that converts between input and output formats (one of which is JSON). It reads from stdin and outputs to stdout. Default behavior is pretty-printed JSON output. The tool provides basic formatting and validation. It's often pre-installed on systems with Perl.
参数
- -f _FORMAT_
- Input format: json (default) or eval (Perl code).
- -t _FORMAT_
- Output format: json (default), dumper (Data::Dumper), or null.
- -json_opt _OPTIONS_
- Comma-separated JSON formatting options: ascii, latin1, utf8, pretty, indent, space_before, space_after, relaxed, canonical, allow_nonref, allow_singlequote, allow_barekey, allow_bignum, loose, escape_slash, indent_length.
- -v
- Verbose mode (currently no action).
- -V
- Print version and exit.
FAQ
What is the json_pp command used for?
json_pp is a JSON::PP command utility that converts between input and output formats (one of which is JSON). It reads from stdin and outputs to stdout. Default behavior is pretty-printed JSON output. The tool provides basic formatting and validation. It's often pre-installed on systems with Perl.
How do I run a basic json_pp example?
Run `json_pp < [data.json]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f _FORMAT_ do in json_pp?
Input format: json (default) or eval (Perl code).