No description
Find a file
Joel Depooter 78180884c6 Handle carriage returns in source JSON whitespace
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.
2025-02-25 11:35:11 -08:00
benches Delete benches/large-file.json 2024-10-06 22:42:08 +02:00
jsonformat-cli prepare for release 2 2022-04-28 21:19:17 +02:00
src Handle carriage returns in source JSON whitespace 2025-02-25 11:35:11 -08:00
.gitignore cleanup 2022-04-28 20:35:33 +02:00
.rustfmt.toml cleanup 2022-04-28 20:35:33 +02:00
Cargo.lock binary cleanup 2022-04-28 21:09:50 +02:00
Cargo.toml add bench to include 2022-04-28 21:21:45 +02:00
CHANGELOG.md prepare for release 2022-04-28 21:16:43 +02:00
LICENSE Create LICENSE 2021-07-17 23:25:44 +02:00
README.md Update README.md 2023-09-22 22:00:45 +02:00

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.