Welcome to zzson
zzson
is a forgiving JSON parser written in Rust, inspired by the JavaScript library jsonic
. It provides robust, flexible parsing for both strict and non-standard JSON, supporting features like comments, unquoted keys, trailing commas, implicit arrays/objects, and more. zzson is available as a Rust library, CLI tool, and WebAssembly module for browser/Node.js usage.
Key Features
- Forgiving parsing: comments, unquoted keys, trailing commas, implicit arrays/objects
- Extended number formats: hex, octal, binary, underscores
- Strict mode for RFC 8259 compliance
- WebAssembly/JavaScript support
- Interactive web tool
Try It Online
๐ Launch the Web Tool โ Parse forgiving JSON in your browser!
Quick Start (Rust)
use zzson::parse;
fn main() {
let data = r#"{ key: 1, /* comment */ arr: [1,2,3,], hex: 0x10 }"#;
let value = parse(data).unwrap();
println!("{:?}", value);
}
Documentation
Contributing
See Contributing for how to help improve zzson.
๐ฆ Download the latest CLI release - Get the zzson
command-line interface for your platform.
Features
- Forgiving Parsing: Handles comments, trailing commas, unquoted keys, and implicit top-level objects/arrays.
- Rust Idiomatic API: Designed with Rustโs ownership, borrowing, and error handling principles in mind.
- Performance: Optimized for speed and efficiency.
- Serde Integration: Seamlessly convert
zzson::Value
to and from other data formats using theserde
framework. - WebAssembly (WASM) Bindings: Use
zzson
directly in JavaScript environments. - Interactive Web Tool: Browser-based parser with real-time feedback and sharing capabilities.
- Compatibility: Aims for API compatibility with the original
jsonic.js
where appropriate.
Getting Started
To use zzson
in your Rust project, add it to your Cargo.toml
:
[dependencies]
zzson = "1.1.0" # Replace with the latest version
Then, you can parse JSON-like strings:
use zzson::parse;
fn main() {
let json_str = r#"
{
// This is a comment
name: "John Doe",
age: 30,
hobbies: [
"reading",
"hiking", // Trailing comma
],
}
"#;
match parse(json_str) {
Ok(value) => {
println!("Parsed successfully: {:?}", value);
}
Err(e) => {
eprintln!("Parsing error: {}", e);
}
}
}
Documentation
Project Status
zzson
is currently in its early development phase. We are actively working on implementing all forgiving features and ensuring high performance and reliability. Contributions are welcome!
License
zzson
is distributed under the MIT License. See the LICENSE file for more details.