Expand description
§JSON streaming parser and serializer
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 allowing to parse larger than memory files.
If you want fast and battle-tested code you might prefer to use json, serde_json or simd-json.
Parser example:
use json_event_parser::{ReaderJsonParser, JsonEvent};
let json = b"{\"foo\": 1}";
let mut reader = ReaderJsonParser::new(json.as_slice());
assert_eq!(reader.parse_next()?, JsonEvent::StartObject);
assert_eq!(reader.parse_next()?, JsonEvent::ObjectKey("foo".into()));
assert_eq!(reader.parse_next()?, JsonEvent::Number("1".into()));
assert_eq!(reader.parse_next()?, JsonEvent::EndObject);
assert_eq!(reader.parse_next()?, JsonEvent::Eof);
Serializer example:
use json_event_parser::{WriterJsonSerializer, JsonEvent};
let mut writer = WriterJsonSerializer::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}");
§License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or
<http://www.apache.org/licenses/LICENSE-2.0>
) - MIT license (LICENSE-MIT or
<http://opensource.org/licenses/MIT>
)
at your option.
§Contribution
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.
Structs§
- Json
Syntax Error - An error in the syntax of the parsed file.
- LowLevel
Json Parser - A low-level JSON parser acting on a provided buffer.
- LowLevel
Json Parser Result - Result of
LowLevelJsonParser::parse_next
. - LowLevel
Json Serializer - A low-level JSON streaming writer writing to a
Write
implementation. - Reader
Json Parser - Parses a JSON file from a
Read
implementation. - Slice
Json Parser - Parses a JSON file from a
&[u8]
. - Text
Position - A position in a text i.e. a
line
number starting from 0, acolumn
number starting from 0 (in number of code points) and a global fileoffset
starting from 0 (in number of bytes). - Tokio
Async Reader Json Parser async-tokio
- Parses a JSON file from an
AsyncRead
implementation. - Tokio
Async Writer Json Serializer async-tokio
- A JSON streaming writer writing to an
AsyncWrite
implementation. - Writer
Json Serializer - A JSON streaming writer writing to a
Write
implementation.
Enums§
- Json
Event - Possible events during JSON parsing.
- Json
Parse Error - A parsing error.
Type Aliases§
- From
Buffer Json Reader Deprecated - From
Read Json Reader Deprecated - From
Tokio Async Read Json Reader Deprecated async-tokio
- LowLevel
Json Reader Deprecated - LowLevel
Json Reader Result Deprecated - LowLevel
Json Writer Deprecated - Parse
Error Deprecated - Syntax
Error Deprecated - ToTokio
Async Write Json Writer Deprecated async-tokio
- ToWrite
Json Writer Deprecated