Skip to main content

Simple Field Mapping

To map fields directly from source to target:
val mapping = Platymap.flow("customer")
    .withFormat(Format.JSON)
    .to("user")
    .map("name").to("fullName")
    .map("email").to("contactEmail")
    .build()

val customerJson = """
    {
        "name": "John Doe",
        "email": "[email protected]",
        "age": 30
    }
"""

val result = mapping.executeToJson(customerJson)
println(result)
This will produce:
{
    "fullName": "John Doe",
    "contactEmail": "[email protected]"
}

Mapping with Transformations

You can transform values during mapping:
val mapping = Platymap.flow("customer")
    .to("user")
    .map("name").transform { it.toString().uppercase() }.to("fullName")
    .map("age").transform { (it as Number).toInt() * 2 }.to("doubledAge")
    .build()

Mapping Nested Fields

You can access nested fields with dot notation:
val mapping = Platymap.flow("customer")
    .to("user")
    .map("address.street").to("streetAddress")
    .map("address.city").to("city")
    .build()

Creating Nested Structures

You can create nested structures in the target:
val mapping = Platymap.flow("customer")
    .to("user")
    .map("email").to("contact.email")
    .map("phone").to("contact.phoneNumber")
    .build()
This will produce a nested “contact” object with “email” and “phoneNumber” fields.