A JSON event parser and serializer

2 releases

0.1.1 Jul 27, 2021
0.1.0 May 30, 2021

#988 in Parser implementations

Download history 312/week @ 2022-12-06 372/week @ 2022-12-13 397/week @ 2022-12-20 513/week @ 2022-12-27 370/week @ 2023-01-03 143/week @ 2023-01-10 275/week @ 2023-01-17 177/week @ 2023-01-24 200/week @ 2023-01-31 168/week @ 2023-02-07 240/week @ 2023-02-14 507/week @ 2023-02-21 199/week @ 2023-02-28 229/week @ 2023-03-07 312/week @ 2023-03-14 204/week @ 2023-03-21

1,166 downloads per month
Used in 7 crates (2 directly)


687 lines

JSON streaming parser

actions status Latest Version Released API docs

JSON event parser is a simple streaming JSON parser and serializer implementation in Rust.

It does not aims to be the fastest or the more versatile JSON parser possible but to be an as simple as possible implementation.

If you want fast and battle-tested code you might prefer to use json, serde_json or simd-json.

Reader example:

use json_event_parser::{JsonReader, JsonEvent};
use std::io::Cursor;

let json = b"{\"foo\": 1}";
let mut reader = JsonReader::from_reader(Cursor::new(json));

let mut buffer = Vec::new();
assert_eq!(JsonEvent::StartObject, reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::ObjectKey("foo"), reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::Number("1"), reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::EndObject, reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::Eof, reader.read_event(&mut buffer)?);

# std::io::Result::Ok(())

Writer example:

use json_event_parser::{JsonWriter, JsonEvent};

let mut buffer = Vec::new();
let mut writer = JsonWriter::from_writer(&mut buffer);

assert_eq!(buffer.as_slice(), b"{\"foo\":1}");

# std::io::Result::Ok(())


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Futures 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