mirror of
https://github.com/Noratrieb/jsonformat.git
synced 2026-01-14 14:15:03 +01:00
No description
Previously any carriage return (\r) bytes in the JSON whitespace were not ignored. Instead they were included in the formatted output. This led to very bad formatting, as the indentation would include the carriage return. With this change, carriage returns are handled the same way that newlines are: they are ignored in the source JSON whitespace. It might be better to detect if the source JSON is using Windows (\r\n) newlines, and preserve that on the output. However, that is a much bigger change. For now I think it is sufficient to simply produce necely formatted output which uses only \n newlines. |
||
|---|---|---|
| benches | ||
| jsonformat-cli | ||
| src | ||
| .gitignore | ||
| .rustfmt.toml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
Extremely fast JSON formatter
jsonformat is an extremely fast JSON formatter.
It formats over 20MB of nested JSON in 60ms.
Library crate
For the library crate, look at docs.rs
Binary Install
You need Rust installed on your system
cargo install jsonformat-cli
Binary Usage
jsonformat-cli 0.2.0
Formats JSON extremely fast
USAGE:
jsonformat [OPTIONS] [INPUT]
ARGS:
<INPUT> The input file
OPTIONS:
-h, --help Print help information
-i, --indentation <INDENTATION> The indentation, s will replaced by a space and t by a tab.
ss is the default
-o, --output <OUTPUT> The output file
-V, --version Print version information
Reads from stdin if no file is supplied. Outputs to stdout if no output file is specified.
Error handling
jsonformat does not report malformed json - it can't even fully know whether the json is actually malformed.
Malformed json is just formatted kind of incorrectly, with no data lost and no crashes. If you find one, open an issue,
How?
jsonformat does not actually parse the json, it just loops through each character and keeps track of some flags.
It then copies these characters to the output buffer, adding and removing whitespace.