ppj-0.1.0 is not a library.
PJ
A simple Rust CLI that prettifies JSON.
Getting Started
- Build:
cargo build - Run:
cargo run - Test:
cargo test
Usage
pj 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.
Basic
- From a positional argument:
cargo run -- '{"key":"value","nums":[1,2]}'
- From stdin:
echo '{"key":"value","nums":[1,2]}' | cargo run
Output to file
Use -o/--out to write the prettified JSON to a file. Parent directories are created if they don’t exist.
cargo run -- '{"key":"value"}' -o output.json
Print and write
Use -p/--print to also print to stdout when writing to a file.
cargo run -- '{"key":"value"}' -o output.json -p
Options
-o, --out <DIR>: Output file path.-p, --print: Print prettified JSON to stdout even when--outis set.
License
MIT