🦀 rson-core
Core parsing and value types for RSON (Rust Serialized Object Notation)
🎯 What is rson-core?
rson-core is the foundational library for RSON (Rust Serialized Object Notation) - a human-readable data format that extends JSON with rich types, comments, and better developer experience.
This crate provides:
- RSON value types - Structs, enums, options, tuples
- Low-level parsing - Tokenization and AST construction
- Core utilities - Validation, formatting, conversion
🚀 Quick Start
Installation
[]
= "1.0.0"
Basic Usage
use ;
// Parse RSON text into value types
let rson_text = r#"
User(
id: 123,
name: "John Doe",
email: Some("john@example.com"),
roles: ["admin", "user"],
)
"#;
let value: RsonValue = parse_rson_value?;
// Work with the parsed value
match value
📚 Core Types
RsonValue Enum
Parsing Functions
use ;
// Parse complete RSON value
let value = parse_rson_value?;
// Tokenize RSON text
let tokens = parse_rson_tokens?;
Validation
use validate_rson;
// Quick validation without full parsing
let is_valid = validate_rson;
🎨 RSON Syntax Examples
Structs
User(
id: 123,
name: "John",
active: true,
)
Enums
Status::Active
Result::Ok("success")
Color::RGB(255, 128, 0)
Options
Some("value")
None
Comments
// Line comment
Config(
/* Block comment */
name: "app",
debug: true, // Trailing comma OK
)
🔧 Advanced Usage
Custom Parsing
use ;
let config = ParserConfig ;
let parser = with_config;
let value = parser.parse?;
Value Manipulation
use RsonValue;
let mut value = Object;
// Add fields to object
if let Object = value
Serialization
use to_rson_string;
let value = Struct;
let rson_text = to_rson_string?;
println!;
// Output: Config(name: "app")
🌍 Integration with Other Crates
With serde_rson
// For high-level Serde integration, use serde_rson
use serde_rson;
use ;
With rson-schema
// For schema validation
use validate_against_schema;
🎯 When to Use rson-core
Use rson-core when:
- Building custom RSON parsers or tools
- Need low-level access to RSON AST
- Creating language bindings for RSON
- Implementing custom serialization logic
Use serde_rson when:
- Working with Rust structs and enums
- Need high-level serialization/deserialization
- Building typical Rust applications
📖 Documentation
- API Documentation - Complete API reference
- RSON Specification - Language specification
- Examples - Usage examples
🤝 Contributing
We welcome contributions! Please see our Contributing Guide.
Areas we need help with:
- Performance optimizations
- Additional parsing features
- Better error messages
- Documentation improvements
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Related Projects
- serde_rson - Serde integration for RSON
- rson-cli - Command-line tools
- rson-schema - Schema validation
- RSON Website - Documentation and playground
Made with 🦀 by the RSON community