json-pretty-compact: A compact & pretty formatter for serde_json.
Introduction
The json_pretty_compact
crate implements a pretty serde_json formatter
which tries to be as compact as possible. This can increase the readability
of formatted JSON.
A compact-pretty formatted JSON looks like this:
Compaction rules
The formatter tries to put arrays and objects into one line, as long as the line length is still within its limit. If a line will become too large, the formatter will change into a pretty format.
Usage
use PrettyCompactFormatter;
use Serialize;
use ;
// Create a JSON value.
// In this simple example it contains only the "true" value.
let value: Value = from_str.unwrap;
// The buffer where the serialized JSON is written.
let mut target = vec!;
// Create the formatter.
// It takes all the default values.
let formatter = new;
// Serialize the JSON value into the `target` buffer.
let mut ser = with_formatter;
value.serialize.unwrap;
assert_eq!;
License
You can check out the full license here.
This project is licensed under the terms of the MIT license.