Crates.io | json-event-parser |
lib.rs | json-event-parser |
version | 0.2.0 |
source | src |
created_at | 2021-05-30 13:32:45.745847 |
updated_at | 2024-03-23 20:39:39.867957 |
description | A JSON event parser and serializer |
homepage | https://github.com/oxigraph/json-event-parser |
repository | https://github.com/oxigraph/json-event-parser |
max_upload_size | |
id | 403831 |
size | 88,571 |
JSON event parser is a simple streaming JSON parser and serializer implementation in Rust.
It does not aims to be the fastest JSON parser possible but to be a simple 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::{FromReadJsonReader, JsonEvent};
let json = b"{\"foo\": 1}";
let mut reader = FromReadJsonReader::new(json.as_slice());
assert_eq!(reader.read_next_event()?, JsonEvent::StartObject);
assert_eq!(reader.read_next_event()?, JsonEvent::ObjectKey("foo".into()));
assert_eq!(reader.read_next_event()?, JsonEvent::Number("1".into()));
assert_eq!(reader.read_next_event()?, JsonEvent::EndObject);
assert_eq!(reader.read_next_event()?, JsonEvent::Eof);
# std::io::Result::Ok(())
Writer example:
use json_event_parser::{ToWriteJsonWriter, JsonEvent};
let mut writer = ToWriteJsonWriter::new(Vec::new());
writer.write_event(JsonEvent::StartObject)?;
writer.write_event(JsonEvent::ObjectKey("foo".into()))?;
writer.write_event(JsonEvent::Number("1".into()))?;
writer.write_event(JsonEvent::EndObject)?;
assert_eq!(writer.finish()?.as_slice(), b"{\"foo\":1}");
# std::io::Result::Ok(())
This project is licensed under either of
<http://www.apache.org/licenses/LICENSE-2.0>
)<http://opensource.org/licenses/MIT>
)at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in json-event-parser by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.