#json #tools #lexer


A zero-copy json-lexer, filters and serializer

10 releases (5 stable)

1.1.2 Feb 1, 2020
1.1.0 Feb 8, 2019
1.0.1 Jan 2, 2017
0.3.0 May 9, 2015
0.0.1 May 6, 2015

#709 in Parser implementations

Download history 41/week @ 2023-02-05 45/week @ 2023-02-12 84/week @ 2023-02-19 129/week @ 2023-02-26 62/week @ 2023-03-05 15/week @ 2023-03-12 48/week @ 2023-03-19 37/week @ 2023-03-26 39/week @ 2023-04-02 37/week @ 2023-04-09 11/week @ 2023-04-16 8/week @ 2023-04-23 66/week @ 2023-04-30 107/week @ 2023-05-07 20/week @ 2023-05-14 91/week @ 2023-05-21

284 downloads per month
Used in 5 crates (3 directly)


540 lines

Build Status

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


  • 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.


Add this to your Cargo.toml

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);


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.


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


Licensed under either of

at your option.


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.

No runtime deps