mirror of
https://github.com/Noratrieb/jsonformat.git
synced 2026-01-14 22:25:01 +01:00
prepare for release
This commit is contained in:
parent
35332a1b26
commit
7aed458197
4 changed files with 30 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
# 2.0.0
|
# 2.0.0
|
||||||
|
|
||||||
There are many changes, the two formatting functions have been renamed, `format_reader_writer` now takes
|
There are many changes, the two formatting functions have been renamed, `format_reader_writer` now takes
|
||||||
a `W` and `R` instead of `&mut BufReader<W>`, it now always adds a trailing newline. There may be a few more
|
a `W` and `R` instead of `&mut BufReader<W>`, it now always adds a trailing newline. `Indentation::Default` was
|
||||||
|
renamed to `Indentation::TwoSpaces` and `FourSpaces` and `Tab` were added. There may be a few more
|
||||||
small changes.
|
small changes.
|
||||||
27
README.md
27
README.md
|
|
@ -4,27 +4,32 @@
|
||||||
|
|
||||||
It formats over 20MB of nested JSON in 60ms.
|
It formats over 20MB of nested JSON in 60ms.
|
||||||
|
|
||||||
For the library, look at [docs.rs](https://docs.rs/jsonformat)
|
## Library crate
|
||||||
|
|
||||||
## Install
|
For the library crate, look at [docs.rs](https://docs.rs/jsonformat)
|
||||||
|
|
||||||
|
## Binary Install
|
||||||
You need Rust installed on your system
|
You need Rust installed on your system
|
||||||
`cargo install jsonformat-cli`
|
`cargo install jsonformat-cli`
|
||||||
|
|
||||||
## Usage
|
## Binary Usage
|
||||||
```
|
```
|
||||||
|
jsonformat-cli 0.2.0
|
||||||
|
Nilstrieb <nilstrieb@gmail.com>
|
||||||
|
Formats JSON extremely fast
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
jsonformat [OPTIONS] [input]
|
jsonformat [OPTIONS] [INPUT]
|
||||||
|
|
||||||
ARGS:
|
ARGS:
|
||||||
<input> The input file to format
|
<INPUT> The input file
|
||||||
|
|
||||||
FLAGS:
|
|
||||||
-h, --help Prints help information
|
|
||||||
-V, --version Prints version information
|
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-i, --indent <indentation> Set the indentation used (\s for space, \t for tab)
|
-h, --help Print help information
|
||||||
-o, --output <output> The output file for the formatted json
|
-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.
|
Reads from stdin if no file is supplied.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{fs, io, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use jsonformat::{format, format_reader_writer, Indentation};
|
use jsonformat::{format, format_reader_writer, Indentation};
|
||||||
|
|
|
||||||
12
src/lib.rs
12
src/lib.rs
|
|
@ -14,8 +14,12 @@ use std::{
|
||||||
/// but nothing is stopping you from doing that.
|
/// but nothing is stopping you from doing that.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||||
pub enum Indentation<'a> {
|
pub enum Indentation<'a> {
|
||||||
/// Use the default indentation, which is two spaces
|
/// Fast path for two spaces
|
||||||
TwoSpace,
|
TwoSpace,
|
||||||
|
/// Fast path for four spaces
|
||||||
|
FourSpace,
|
||||||
|
/// Fast path for tab
|
||||||
|
Tab,
|
||||||
/// Use a custom indentation String
|
/// Use a custom indentation String
|
||||||
Custom(&'a str),
|
Custom(&'a str),
|
||||||
}
|
}
|
||||||
|
|
@ -142,6 +146,12 @@ where
|
||||||
Indentation::TwoSpace => {
|
Indentation::TwoSpace => {
|
||||||
writer.write_all(b" ")?;
|
writer.write_all(b" ")?;
|
||||||
}
|
}
|
||||||
|
Indentation::FourSpace => {
|
||||||
|
writer.write_all(b" ")?;
|
||||||
|
}
|
||||||
|
Indentation::Tab => {
|
||||||
|
writer.write_all(b"\t")?;
|
||||||
|
}
|
||||||
Indentation::Custom(indent) => {
|
Indentation::Custom(indent) => {
|
||||||
writer.write_all(indent.as_bytes())?;
|
writer.write_all(indent.as_bytes())?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue