Skip to main content

Basic Combinations

Simple Joining

Combine fields with a space separator:
.map("firstName", "lastName").to("fullName").end()
Input:
{
  "firstName": "John",
  "lastName": "Doe"
}
Output:
{
  "fullName": "John Doe"
}

Custom Separators

Join fields with any separator:
.map("street", "city", "state", "zip").to("address").joinWith(", ")
Input:
{
  "street": "123 Main St",
  "city": "Anytown",
  "state": "CA",
  "zip": "12345"
}
Output:
{
  "address": "123 Main St, Anytown, CA, 12345"
}

No Separator

Concatenate fields without separators:
.map("countryCode", "areaCode", "number").to("rawPhone").concatenate()
Input:
{
  "countryCode": "1",
  "areaCode": "555",
  "number": "1234567"
}
Output:
{
  "rawPhone": "15551234567"
}

Transforming Combinations

Applying Transformers

Apply transformations to combined fields:
.map("firstName", "lastName").to("fullName").uppercase().end()
Input:
{
  "firstName": "John",
  "lastName": "Doe"
}
Output:
{
  "fullName": "JOHN DOE"
}

Custom Transformations

Create custom formatting:
.map("areaCode", "number")
    .transform { values ->
        val list = values as List<*>
        val area = list.getOrNull(0)?.toString() ?: ""
        val num = list.getOrNull(1)?.toString() ?: ""
        DataNode.StringValue("($area) $num")
    }
    .to("formattedPhone")
    .end()
Input:
{
  "areaCode": "555",
  "number": "1234567"
}
Output:
{
  "formattedPhone": "(555) 1234567"
}

Common Use Cases

Name Formatting

Format names with titles:
.map("title", "firstName", "lastName")
    .transform { values ->
        val list = values as List<*>
        val title = list.getOrNull(0)?.toString() ?: ""
        val first = list.getOrNull(1)?.toString() ?: ""
        val last = list.getOrNull(2)?.toString() ?: ""
        
        if (title.isNotEmpty()) {
            DataNode.StringValue("$title. $first $last")
        } else {
            DataNode.StringValue("$first $last")
        }
    }
    .to("formattedName")
    .end()
Input:
{
  "title": "Dr",
  "firstName": "Jane",
  "lastName": "Smith"
}
Output:
{
  "formattedName": "Dr. Jane Smith"
}

Address Formatting

Format addresses:
.map("street", "apt")
    .transform { values ->
        val list = values as List<*>
        val street = list.getOrNull(0)?.toString() ?: ""
        val apt = list.getOrNull(1)?.toString() ?: ""
        
        if (apt.isNotEmpty()) {
            DataNode.StringValue("$street, Apt $apt")
        } else {
            DataNode.StringValue(street)
        }
    }
    .to("streetAddress")
    .end()
Input:
{
  "street": "123 Main St",
  "apt": "4B"
}
Output:
{
  "streetAddress": "123 Main St, Apt 4B"
}

Email Generation

Generate an email from name parts:
.map("firstName", "lastName", "domain")
    .transform { values ->
        val list = values as List<*>
        val first = list.getOrNull(0)?.toString()?.lowercase() ?: ""
        val last = list.getOrNull(1)?.toString()?.lowercase() ?: ""
        val domain = list.getOrNull(2)?.toString() ?: ""
        
        DataNode.StringValue("$first.$last@$domain")
    }
    .to("email")
    .end()
Input:
{
  "firstName": "John",
  "lastName": "Doe",
  "domain": "example.com"
}
Output:
{
  "email": "[email protected]"
}

Method Reference

MethodDescriptionExample
map(field1, field2, ...)Start a multi-field mapping.map("first", "last")
to(targetField)Specify target field.to("fullName")
end()Finalize the mapping.end()
joinWith(separator)Join with custom separator.joinWith(", ")
concatenate()Join without separators.concatenate()
transform(function)Apply custom transformation.transform { ... }
You can combine these methods with any standard transformers (uppercase(), trim(), etc.) to further process the combined result.