Oak Django Parser
A high-performance Django template parser with streaming support, built on oak-core for efficient template parsing and validation.
🎯 Overview
oak-django is a fast and memory-efficient Django template parser designed to handle Django template syntax including template tags, filters, and variables. Built on the reliable oak-core foundation, it provides comprehensive template parsing with excellent error reporting and validation capabilities.
✨ Features
- Streaming Support: Parse large JSON files without loading entirely into memory
- RFC 7159 Compliant: Full compliance with JSON specification
- Zero-Copy: Efficient parsing with minimal memory allocations
- Error Recovery: Detailed error messages with line/column information
- Type Validation: Strict type checking and validation
- Fast Performance: Optimized for speed and memory efficiency
🚀 Quick Start
Basic example:
use JsonParser;
📋 Parsing Examples
Object Parsing
use ;
let parser = new;
let json = r#"{
"user": {
"id": 123,
"name": "Alice",
"roles": ["admin", "user"]
},
"settings": {
"theme": "dark",
"notifications": true
}
}"#;
let value = parser.parse?;
if let Object = value
Array Parsing
use ;
let parser = new;
let json = r#"[
{"id": 1, "name": "Item 1", "price": 10.50},
{"id": 2, "name": "Item 2", "price": 25.99},
{"id": 3, "name": "Item 3", "price": 7.25}
]"#;
let value = parser.parse?;
if let Array = value
Streaming Large Files
use ;
use File;
use BufReader;
let parser = new;
let file = open?;
let reader = new;
// Parse large JSON files efficiently
let value = parser.parse_reader?;
println!;
🔧 Advanced Features
Custom Validation
use ;
let parser = new;
let json = r#"{
"username": "john_doe",
"age": 25,
"email": "john@example.com"
}"#;
let value = parser.parse?;
// Validate required fields
validate_user?;
Partial Parsing
use ;
let parser = new;
let json = r#"{
"users": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
],
"total": 2
}"#;
// Parse only specific parts
let users = parser.parse_path?;
println!;
Error Handling
use JsonParser;
let parser = new;
let invalid_json = r#"{
"name": "John",
"age": 30,
"active": true,
"scores": [85, 92, "invalid", 78]
}"#;
match parser.parse
🏗️ JSON Structure
The parser generates a comprehensive JSON value structure:
- JsonValue::Null: JSON null values
- JsonValue::Bool: Boolean true/false
- JsonValue::Number: Numeric values (integers and floats)
- JsonValue::String: String values
- JsonValue::Array: Ordered collections of values
- JsonValue::Object: Key-value mappings
📊 Performance
- Streaming: Parse multi-GB JSON files with minimal memory usage
- Zero-Copy: Efficient string handling with minimal allocations
- Fast Parsing: Optimized parser for maximum throughput
- Incremental: Support for incremental parsing of partial data
🔗 Integration
oak-json integrates seamlessly with:
- Web APIs: Parse JSON responses from HTTP APIs
- Configuration Files: Handle application configuration in JSON format
- Data Processing: Process large JSON datasets efficiently
- Logging: Parse structured log data in JSON format
- Testing: Generate and validate test data in JSON
📚 Examples
Check out the examples directory for comprehensive examples:
- Basic JSON parsing and validation
- Streaming large JSON files
- Custom validation and error handling
- Partial parsing with JSONPath
- Performance benchmarks
🤝 Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Pex JSON Parser - Fast, reliable JSON parsing for Rust applications 🚀