2 releases
new 0.1.2 | Nov 2, 2024 |
---|---|
0.1.1 | Nov 2, 2024 |
#622 in Data structures
191 downloads per month
13KB
181 lines
datamorph-rs
A powerful Rust library for transforming data structures using declarative specifications with JSONLogic support. Built for performance, type safety, and extensibility.
Overview
datamorph-rs
allows you to transform data structures using simple array-based specifications with JSONLogic conditions. It's designed to be easy to use while remaining flexible and extensible.
Features
- 🚀 Simple, array-based transformation specifications
- 🔧 Built-in transformation functions
- 🎯 Type-safe transformations
- 🔄 Field, concatenation, and split operations
- ⚡ Conditional transformations with JSONLogic
- 📝 Clear error messages
Quick Start
Add to your Cargo.toml
:
[dependencies]
datamorph-rs = "0.1.0"
serde_json = "1.0"
Basic example:
use datamorph_rs::Datamorph;
use serde_json::json;
// Define your transformation spec
let spec = r#"[
{
"type": "field",
"source": "name",
"target": "fullName",
"transform": "uppercase",
"condition": {
"!!": {"var": "name"}
}
},
{
"type": "concat",
"sources": ["city", "country"],
"target": "location",
"separator": ", "
}
]"#;
// Create transformer
let transformer = Datamorph::from_json(spec)?;
// Transform data
let input = json!({
"name": "john doe",
"city": "New York",
"country": "USA"
});
let result: serde_json::Value = transformer.transform(input)?;
println!("Result: {}", serde_json::to_string_pretty(&result)?);
Documentation
- Usage Guide - Detailed usage instructions
- API Reference - Complete API documentation
- Examples - Example implementations
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Dependencies
~2.2–3.5MB
~62K SLoC