jzon-rs 0.1.0

Zero-copy JSON serialization with compile-time generated typed parsers
Documentation

jzon-rs

crates.io docs.rs CI

Zero-copy JSON for Rust with compile-time generated parsers.

Quick Start

[dependencies]
jzon-rs = "0.1"
use jzon::{ToJson, FromJson};

#[derive(ToJson, FromJson)]
struct Event<'a> {
    id: u64,
    name: &'a str,   // zero-copy — points directly into the input buffer
    tags: Vec<&'a str>,
}

fn main() {
    let src = r#"{"id":1,"name":"launch","tags":["rust","json"]}"#;
    let ev: Event = Event::from_json_str(src).unwrap();
    println!("{}", ev.to_json_string());
}

Highlights

  • Zero-copy&'a str fields borrow directly from the input; no heap allocation for string data.
  • SIMD scanning — uses vectorised byte-search on x86-64 and aarch64 for structural character detection.
  • No unsafe in user code — the derive macros emit fully safe Rust.
  • serde attribute compatibility#[serde(rename = "…")], #[serde(skip_serializing_if)], etc. are honoured by the derive macros.

Performance

Benchmarked on Apple M2, rustc 1.78, release mode, criterion 0.5.

Dataset jzon serde_json sonic-rs
twitter de ★ 316 µs 327 µs 345 µs
canada de ★ 2.43 ms 3.51 ms 3.03 ms
micro Point de ★ 41 ns 74 ns 63 ns

Other Crates

Crate Purpose
jzon-rs-serde SIMD-backed serde Serializer/Deserializer for any serde-deriving type
jzon-rs-compat Drop-in serde_json replacement via Cargo's [patch] mechanism

License

MIT


Made with ❤️ by Rajaniraiyn