mirror of
https://codeberg.org/MicroPanda123/zasa.git
synced 2025-02-17 20:01:37 +00:00
No description
zasa | ||
zasa-core | ||
zasa-derive | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
LICENSE.txt | ||
README.md |
Żasą
It's just own json parser writen only in rust, with 0 external dependencies, as part of my "No dependncies" series of projects.
Usage
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,
}