Vexy JSON Features Overview¶
Vexy JSON is a comprehensive JSON parsing library that provides robust, forgiving JSON parsing with advanced features for transformation, repair, and optimization.
Core Features¶
Forgiving JSON Parsing¶
Vexy JSON accepts JSON that would be rejected by standard parsers:
use vexy_json_core::parse;
// Comments are allowed
let json = r#"
{
"name": "John", // Person's name
"age": 30 /* Person's age */
}
"#;
// Trailing commas are fine
let json = r#"{"items": [1, 2, 3,]}"#;
// Unquoted keys work
let json = r#"{name: "John", age: 30}"#;
// Single quotes are supported
let json = r#"{'name': 'John', 'age': 30}"#;
// Newlines can act as commas
let json = r#"
{
"a": 1
"b": 2
}
"#;
Multiple Parser Implementations¶
Vexy JSON provides several parser implementations optimized for different use cases:
- Standard Parser: Full-featured with all forgiving capabilities
- Optimized Parser: Performance-focused with reduced memory allocation
- Optimized Parser V2: Enhanced version with additional optimizations
- Recursive Descent Parser: Clean, maintainable recursive implementation
- Iterative Parser: Stack-based parser for deep JSON structures
Advanced Features¶
JSON Transformation¶
Normalization¶
Standardize JSON format for consistent processing:
use vexy_json_core::transform::normalize;
let json = r#"{"z": 1, "a": 2, "b": null}"#;
let normalized = normalize(json).unwrap();
// Result: {"a": 2, "b": null, "z": 1}
Optimization¶
Improve JSON structure for performance:
use vexy_json_core::transform::optimize;
let json = r#"{"count": 42.0, "price": 19.0}"#;
let optimized = optimize(&json).unwrap();
// Numbers optimized: {"count": 42, "price": 19}
JSON Repair¶
Automatically fix common JSON issues:
use vexy_json_core::repair::JsonRepairer;
let mut repairer = JsonRepairer::new(10);
let broken = r#"{"key": "value", "missing": "quote}"#;
let (fixed, repairs) = repairer.repair(broken).unwrap();
Streaming Support¶
Process large JSON files efficiently:
use vexy_json_core::streaming::parse_streaming;
for value in parse_streaming(reader)? {
// Process each JSON value as it's parsed
process(value?);
}
Parallel Processing¶
Parse multiple JSON documents simultaneously:
use vexy_json_core::parallel::parse_parallel;
let results = parse_parallel(&json_strings, ParallelConfig::default())?;
Language Bindings¶
Python Integration¶
Full-featured Python bindings with NumPy and Pandas support:
import vexy_json
# Standard JSON parsing
data = vexy_json.loads('{"name": "John", "age": 30}')
# NumPy integration
import numpy as np
array = vexy_json.loads_numpy('[1, 2, 3, 4, 5]')
# Pandas integration
import pandas as pd
df = vexy_json.loads_dataframe('[{"a": 1, "b": 2}, {"a": 3, "b": 4}]')
# Streaming support
with vexy_json.StreamingParser() as parser:
for item in parser.parse_stream(file_handle):
process(item)
WebAssembly Support¶
Run Vexy JSON in browsers and JavaScript environments:
import init, { parse } from 'vexy_json-wasm';
await init();
const result = parse('{"name": "John", age: 30}');
Performance Features¶
Memory Optimization¶
- String Interning: Deduplicate repeated strings
- Zero-Copy Parsing: Minimize memory allocations
- Lazy Evaluation: Parse only what's needed
Speed Optimization¶
- SIMD Instructions: Vectorized operations where available
- Optimized Hot Paths: Fast paths for common cases
- Parallel Processing: Multi-threaded parsing for large datasets
Error Handling and Recovery¶
Comprehensive Error Reporting¶
use vexy_json_core::parse;
match parse(invalid_json) {
Ok(value) => println!("Parsed: {:?}", value),
Err(error) => {
println!("Parse error at position {}: {}",
error.position(), error.description());
}
}
Automatic Recovery¶
use vexy_json_core::parser::parse_with_fallback;
// Tries multiple parsing strategies automatically
let result = parse_with_fallback(input, options);
Repair with Confidence Scoring¶
use vexy_json_core::repair::advanced::AdvancedJsonRepairer;
let mut repairer = AdvancedJsonRepairer::new();
let (fixed, strategies) = repairer.repair(input)?;
for strategy in strategies {
println!("Applied repair: {} (confidence: {:.2})",
strategy.action.description,
strategy.confidence.value());
}
Plugin System¶
Extend Vexy JSON with custom functionality:
use vexy_json_core::plugin::Plugin;
struct CustomPlugin;
impl Plugin for CustomPlugin {
fn on_parse_start(&mut self, input: &str) -> Result<()> {
// Custom pre-processing
Ok(())
}
fn transform_value(&mut self, value: &mut Value, path: &str) -> Result<()> {
// Custom value transformation
Ok(())
}
}
Built-in Plugins¶
Schema Validation¶
use vexy_json_core::plugin::SchemaValidationPlugin;
let plugin = SchemaValidationPlugin::new(schema);
// Validates JSON against schema during parsing
Date/Time Parsing¶
use vexy_json_core::plugin::DateTimePlugin;
let plugin = DateTimePlugin::new();
// Automatically parses ISO 8601 date strings
Comment Preservation¶
use vexy_json_core::plugin::CommentPreservationPlugin;
let plugin = CommentPreservationPlugin::new();
// Preserves comments in parsed JSON
Testing and Fuzzing¶
Comprehensive Test Suite¶
- Unit Tests: Test individual components
- Integration Tests: Test full parsing workflows
- Property Tests: Test with generated inputs
- Fuzzing Tests: Test with random inputs
Continuous Integration¶
- Cross-Platform Testing: Linux, macOS, Windows
- Multiple Rust Versions: Stable, beta, nightly
- Performance Regression Detection: Automatic benchmarking
Documentation and Examples¶
API Documentation¶
Complete rustdoc documentation for all public APIs.
Example Programs¶
- Basic Usage: Simple parsing examples
- Advanced Features: Complex parsing scenarios
- Performance: Benchmarking and optimization
- Integration: Using Vexy JSON with other libraries
Migration Guides¶
- From serde_json: How to migrate existing code
- From other parsers: Comparison and migration tips
Use Cases¶
Web Development¶
- API Parsing: Handle inconsistent API responses
- Configuration: Parse config files with comments
- Data Processing: Transform and normalize JSON data
Data Science¶
- NumPy Integration: Parse JSON directly to arrays
- Pandas Integration: Convert JSON to DataFrames
- Streaming: Process large datasets efficiently
Systems Programming¶
- High Performance: Optimized parsing for speed
- Low Memory: Efficient memory usage
- Reliability: Robust error handling
Cross-Platform Development¶
- Rust Libraries: Native Rust performance
- Python Extensions: Fast Python bindings
- Web Applications: WebAssembly support
Future Roadmap¶
Planned Features¶
- Additional Language Bindings: JavaScript, Go, Java
- Enhanced Streaming: More streaming formats
- Advanced Optimization: Further performance improvements
- Schema Evolution: Automatic schema migration
Community Contributions¶
Vexy JSON welcomes contributions in:
- Feature Development: New parsing features
- Performance Optimization: Speed and memory improvements
- Documentation: Examples and guides
- Testing: Additional test cases and fuzzing
This comprehensive feature set makes Vexy JSON suitable for a wide range of JSON processing needs, from simple parsing to complex data transformation and analysis.