datamorph-rs

Crates.iodatamorph-rs
lib.rsdatamorph-rs
version0.1.2
sourcesrc
created_at2024-11-02 14:03:07.542804
updated_at2024-11-02 14:16:33.652962
descriptionData transformation library using declarative specifications
homepagehttps://openpayments.tech
repositoryhttps://github.com/Open-Payments/datamorph-rs
max_upload_size
id1432901
size38,277
Harishankar Narayanan (codetiger)

documentation

README

datamorph-rs

A powerful Rust library for transforming data structures using declarative specifications with JSONLogic support. Built for performance, type safety, and extensibility.

Crates.io Documentation License

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

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.

Commit count: 17

cargo fmt