Crates.io | yajlish |
lib.rs | yajlish |
version | 0.4.0 |
source | src |
created_at | 2020-08-12 16:43:49.139938 |
updated_at | 2021-10-11 05:25:07.64884 |
description | An event-based json parser with json-ndjson parser |
homepage | |
repository | https://github.com/boydjohnson/yajlish |
max_upload_size | |
id | 275874 |
size | 73,387 |
Write tools to parse json when you don't know its exact structure and can't load it all into memory.
Suppose you wanted to parse the count of all JSON object keys that are named 'foo'.
use yajlish::{Context, Handler, Status};
pub struct FooCountHandler {
count: usize,
}
impl Handler for FooCountHandler {
fn handle_map_key(&mut self, _ctx: &Context, key: &str) -> Status {
if key == "\"foo\"" {
self.count += 1;
}
Status::Continue
}
fn handle_null(&mut self, _ctx: &Context) -> Status {
Status::Continue
}
fn handle_bool(&mut self, _ctx: &Context, boolean: bool) -> Status {
Status::Continue
}
fn handle_double(&mut self, _ctx: &Context, val: f64) -> Status {
Status::Continue
}
fn handle_int(&mut self, _ctx: &Context, val: i64) -> Status {
Status::Continue
}
fn handle_string(&mut self, _ctx: &Context, val: &str) -> Status {
Status::Continue
}
fn handle_start_map(&mut self, _ctx: &Context) -> Status {
Status::Continue
}
fn handle_start_array(&mut self, _ctx: &Context) -> Status {
Status::Continue
}
fn handle_end_map(&mut self, _ctx: &Context) -> Status {
Status::Continue
}
fn handle_end_array(&mut self, _ctx: &Context) -> Status {
Status::Continue
}
}
This library is licensed under the Apache 2.0 License.