A simple Rust CLI that prettifies JSON.
- Install:
cargo install ppj - Build:
cargo build - Run:
ppj - Test:
cargo test
ppj accepts a JSON string as a positional argument, or reads JSON from stdin when no positional input is provided. It outputs pretty-printed JSON to stdout by default.
- From a positional argument:
ppj '{"key":"value","nums":[1,2]}'
- From stdin:
echo '{"key":"value","nums":[1,2]}' | ppj
Use -o/--out to write the prettified JSON to a file. Parent directories are created if they don’t exist.
ppj '{"key":"value"}' -o output.json
Use -p/--print to also print to stdout when writing to a file.
ppj '{"key":"value"}' -o output.json -p
-o, --out <DIR>: Output file path.-p, --print: Print prettified JSON to stdout even when--outis set.
MIT