Crates.io | zasa |
lib.rs | zasa |
version | |
source | src |
created_at | 2024-11-06 19:30:03.781734 |
updated_at | 2024-12-10 17:10:35.276695 |
description | Simple JSON parser with no dependencies |
homepage | https://codeberg.org/micropanda123/zasa |
repository | https://codeberg.org/micropanda123/zasa |
max_upload_size | |
id | 1438708 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
It's just own json parser writen only in rust, with 0 external dependencies, as part of my "No dependncies" series of projects.
Easiest way to use this library is to use it with Normalize
macro, however it's still pretty unstable, but it works for basic stuff. Currently it supports String, f64 and bool types
use zasa::parser::Parser;
use zasa::value::normalize;
use zasa::Normalize;
#[derive(Debug, Normalize)]
struct Example {
name: String,
size: f64,
active: bool
}
fn main() {
let json_string = "{\"name\": \"test\", \"size\": 45.0, \"active\": true}";
let parsed = Parser::new(json_string.chars()).parse().unwrap();
let normalized: Example = normalize(parsed).unwrap();
dbg!(normalized);
}
it will result in
normalized = Example {
name: "test",
size: 45.0,
active: true,
}