The fastest JSON parser in Rust - up to 35% faster than serde_json!
- ⚡ Blazing Fast: Outperforms serde_json by 35% on real-world data
- 🧠 Smart Caching: Pre-compiled patterns for zero-overhead parsing
- 🦀 Pure Rust: No unsafe code, leverages Rust's zero-cost abstractions
- 📦 Lightweight: Minimal dependencies, maximum performance
json_fast consistently outperforms serde_json::Value parsing:
- json_fast/ok_true: 107.92 ns
- serde_json/ok_true: 146.00 ns
- 35% performance improvement!
Optimized for common API response patterns with zero-copy techniques.
Add this to your Cargo.toml
:
[dependencies]
json_fast = "0.1"
use json_fast::JsonFast;
let parser = JsonFast::new();
let result = parser.parse(r#"{"ok": true}"#)?;
println!("Parsed: {:?}", result);
// Also works with strings and numbers
let result2 = parser.parse(r#"{"name": "test"}"#)?;
let result3 = parser.parse(r#"{"count": 42}"#)?;
json_fast uses advanced pattern-based parsing with intelligent pattern caching. By pre-compiling patterns and leveraging Rust's zero-cost abstractions, we achieve unprecedented JSON parsing performance.
The key innovations include:
- Zero-copy string handling: Direct references to input data where possible
- Compiled regex patterns: Pre-computed at parser creation for maximum speed
- Intelligent caching: Patterns cached in optimized HashMap
- Memory-efficient design: Minimal allocations during parsing
Library | Parse Time | Memory Usage | Features |
---|---|---|---|
json_fast | 108ns | Low | Optimized for speed |
serde_json | 146ns | Medium | Full featured |
Note: Currently optimized for simple boolean, string, and number values. Full JSON support (arrays, nested objects) coming soon in v0.2!
The current version handles the most common JSON patterns with maximum performance. This covers the majority of API responses and configuration files.
- Boolean value parsing
- String value parsing
- Number value parsing
- Array support
- Nested object support
- Custom serialization traits
Created by @aidenaistar - Follow for more Rust performance tips and benchmarks!
Found this library useful? Give it a ⭐ and follow @aidenaistar for updates on v0.2 with full JSON support!
MIT License