Crate formatjson
source ·Expand description
Validate and format JSON files.
The formatjson
command is available as a binary, which reads and formats
JSON files in-place, and library functions are available to use or extend
the functionality.
§Examples
-
As a command-line tool:
$ formatjson example.json Successfully formatted example.json
-
As a library:
fn main() { let json = formatjson::format_json(r#"{"foo":"bar"}"#).unwrap(); println!("{}", json); }
$ cargo run { "foo": "bar" }
Re-exports§
pub use errors::FormatJsonError;
Modules§
- Errors raised by the library.
- Contains the token formatter struct, which consumes and formats tokens.
- Tokenizes a given JSON string, without validating its syntax.
- Validates the tokens generated by the tokenizer.
Functions§
- Returns a new, formatted JSON string.
- Reads, formats, and overwrites the given JSON file.