Configuring mapping sources
In a mapping, the source
can be a field, expression, or a static value. Based on the source type given, the value can be extracted in various ways.
Field in columnar data
When mapping a field in columnar data, such as a CSV file, use the ATTRIBUTE
source type. If the field contains .
within its name, use \
to escape the value. An example of this mapping can be found below:
Sample CSV file:
Full.Name, Email
John Smith, js@example.com
Sample mapping
{
"source": "Full.Name",
"destination": "pi.name",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": {
"name": "John Smith"
}
}
Field in nested data
When mapping a field in nested data, such as a JSON file, use the ATTRIBUTE
source type. If the field contains .
within its name, use \
to escape the value. An example of this mapping can be found below:
Sample JSON file
{
"customerInfo": {
"name": "John Smith",
"email": "js@example.com"
}
}
Sample mapping
{
"source": "customerInfo.name",
"destination": "pi.name",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": {
"name": "John Smith"
}
}
Field within an array
When mapping a field within an array, you can retrieve a specific value by using an index. To do this, use the ATTRIBUTE
source type and the index of the value you want to map. An example of this mapping can be found below:
Sample JSON file
{
"customerInfo": {
"emails": [
{
"name": "John Smith",
"email": "js@example.com"
},
{
"name": "Jane Smith",
"email": "jane@example.com"
}
]
}
}
Sample mapping
{
"source": "customerInfo.emails[0].email",
"destination": "pi.email",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": {
"email": "js@example.com"
}
}
Array to array or object to object
Using the ATTRIBUTE
source type, you can also directly map an array to an array or an object to an object. An example of this mapping can be found below:
Sample JSON file
{
"customerInfo": {
"emails": [
{
"name": "John Smith",
"email": "js@example.com"
},
{
"name": "Jane Smith",
"email": "jane@example.com"
}
]
}
}
Sample mapping
{
"source": "customerInfo.emails",
"destination": "pi.emailList",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": {
"emailList": [
{
"name": "John Smith",
"email": "js@example.com"
},
{
"name": "Jane Smith",
"email": "jane@example.com"
}
]
}
}
Iterative operations on arrays
Using the ATTRIBUTE
source type, you can iteratively loop through arrays and map them to a target schema by using a wildcard index ([*]
). An example of this mapping can be found below:
Sample JSON file
{
"customerInfo": {
"emails": [
{
"name": "John Smith",
"email": "js@example.com"
},
{
"name": "Jane Smith",
"email": "jane@example.com"
}
]
}
}
Sample mapping
{
"source": "customerInfo.emails[*].name",
"destination": "pi[*].names",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": [
{
"names": {
"name": "John Smith"
}
},
{
"names": {
"name": "Jane Smith"
}
}
]
}
Constant value
If you want to map a constant, or a static value, use the STATIC
source type. When using the STATIC
source type, the source
represents the hard-coded value that you want to assign to the destination
. An example of this mapping can be found below:
Sample JSON file
{
"name": "John Smith",
"email": "js@example.com"
}
Sample mapping
{
"source": "CUSTOMER",
"destination": "userType",
"sourceType": "STATIC"
}
Transformed data
{
"userType:": "CUSTOMER"
}
Expressions
If you want to map an expression, use the EXPRESSION
source type. A list of accepted functions can be found in the mapping functions guide. When using the EXPRESSION
source type, the source
represents the function you want to resolve. An example of this mapping can be found below:
Sample JSON file
{
"firstName": "John",
"lastName": "Smith",
"email": "js@example.com"
}
Sample mapping
{
"source": "concat(upper(lastName), upper(firstName), now())",
"destination": "pi.created",
"sourceType": "EXPRESSION"
}
Transformed data
{
"pi": {
"created": "SMITHJOHNFri Sep 25 15:17:31 PDT 2020"
}
}
Configuring mapping destinations
In a mapping, the destination
is the location where the value extracted from the source
will be inserted.
Field at the root level
When you want to map the source
value to the root level of your transformed data, follow the example below:
Sample JSON file
{
"customerInfo": {
"name": "John Smith",
"email": "js@example.com"
}
}
Sample mapping
{
"source": "customerInfo.name",
"destination": "name",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"name": "John Smith"
}
Nested field
When you want to map the source
value to a nested field in your transformed data, follow the example below:
Sample JSON file
{
"name": "John Smith",
"email": "js@example.com"
}
Sample mapping
{
"source": "name",
"destination": "pi.name",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": {
"name": "John Smith"
}
}
Field at a specific array index
When you want to map the source
value to a specific index in an array in your transformed data, follow the example below:
Sample JSON file
{
"customerInfo": {
"name": "John Smith",
"email": "js@example.com"
}
}
Sample mapping
{
"source": "customerInfo.name",
"destination": "piList[0]",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"piList": ["John Smith"]
}
Iterative array operation
When you want to iteratively loop through arrays and map the values to the target, you can use a wildcard index ([*]
). An example of this can be seen below:
{
"customerInfo": {
"emails": [
{
"name": "John Smith",
"email": "js@example.com"
},
{
"name": "Jane Smith",
"email": "jane@example.com"
}
]
}
}
Sample mapping
{
"source": "customerInfo.emails[*].name",
"destination": "pi[*].names",
"sourceType": "ATTRIBUTE"
}
Transformed data
{
"pi": [
{
"names": {
"name": "John Smith"
}
},
{
"names": {
"name": "Jane Smith"
}
}
]
}