json-tools

Crates.iojson-tools
lib.rsjson-tools
version1.1.3
sourcesrc
created_at2015-05-06 11:59:44.922434
updated_at2024-07-25 07:48:37.611849
descriptionA zero-copy json-lexer, filters and serializer.
homepage
repositoryhttps://github.com/Byron/json-tools
max_upload_size
id2041
size72,189
Sebastian Thiel (Byron)

documentation

https://docs.rs/crate/json-tools

README

Crates.io Rust

This library contains a collection of tools to help interacting with json encoded data.

Features

  • Simple Json Lexer
    • Without any intention of being feature complete, it is able to split ascii json data streams into their lexical tokens, keeping track of the character spans that make them up.
    • facilitates writing higher-level parsers and filters
  • Key-Value Filter
    • A utility to filter lexical tokens which belong to keys that have values of a given type. This makes it easy to re-assemble json data streams and strip them off their null values, for example.
  • TokenReader
    • An adapter to convert a stream of Tokens into a stream of bytes, supprting the Read trait.
    • Use it to convert filtered and/or manipulated token-streams back into byte-streams.
    • Configure the output style, to achieve effects like pretty-printing or strip the output of all whitespace.

Usage

Add this to your Cargo.toml

[dependencies]
json-tools = "*"

Add this to your lib ...

use json_tools::BufferType;
use json_tools::Lexer;

for token in Lexer::new(r#"{ "face": "😂" }"#.bytes(), BufferType::Span) {
	println!("{:?}", token);
}

Motivation

This library may possibly never grow bigger than the two features originally mentioned, as it was created as a workaround to missing features in serde.

Manual

Run tests with cargo test and benchmarks with cargo bench (works on stable).

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 73

cargo fmt