Skip to main content

Version: 19.05 (EOL)

Traversing JSON properties

Instead of storing values in multiple Journey Manager Txn properties, you can also store values on a single property in a JSON object and use them in Workspaces.

Let's see how we can modify the following example:

Txn properties
{
"Applicants.PrimaryType": "Primary",
"Applicants.PrimaryEmail": "[email protected]",
"Applicants.PrimaryName": "David Gilmore",
"Applicants.PrimarySSN": "122-313-3443",
"Applicants.SecondaryType": "Secondary",
"Applicants.SecondaryEmail": "[email protected]",
"Applicants.SecondaryName": "Matt Green",
"Applicants.SecondarySSN": "111-233-1234"
}
Global mappings config
{
"$primaryType": {
"label": "Type",
"dataIndex": "properties['Applicants.PrimaryType']",
"type": "text"
},
"$primaryName": {
"label": "Name",
"dataIndex": "properties['Applicants.PrimaryName']",
"type": "text"
},
"$primaryEmail": {
"label": "Email",
"dataIndex": "properties['Applicants.PrimaryEmail']",
"type": "text"
},
"$primarySSN": {
"label": "SSN",
"dataIndex": "properties['Applicants.PrimarySSN']",
"type": "text"
},
"$secondaryType": {
"label": "Type",
"dataIndex": "properties['Applicants.SecondaryType']",
"type": "text"
},
"$secondaryName": {
"label": "Name",
"dataIndex": "properties['Applicants.SecondaryName']",
"type": "text"
},
"$secondaryEmail": {
"label": "Email",
"dataIndex": "properties['Applicants.SecondaryEmail']",
"type": "text"
},
"$secondarySSN": {
"label": "SSN",
"dataIndex": "properties['Applicants.SecondarySSN']",
"type": "text"
}
}
Applicants config
{
"applicants": [
{
"label": "Primary",
"properties": [
"$primaryType",
"$primaryEmail",
"$primaryEmail",
"$primarySSN"
]
},
{
"label": "Secondary",
"properties": [
"$secondaryType",
"$secondaryName",
"$secondaryEmail",
"$secondarySSN"
]
}
]
}

The example above can become more complex when adding more applicant properties on the Txn properties, but this can be improved by changing the way we store the "Applicants" information into a single JSON property.

Refactored Txn properties
{
"Applicants": "[{\"type\":\"Primary\",\"email\":\"[email protected]\",\"name\":\"David Gilmore\",\"ssn\":\"122-313-3443\"},{\"type\":\"Secondary\",\"email\":\"[email protected]\",\"name\":\"Matt Green\",\"ssn\":\"111-233-1234\"}]"
}

Using the dataSource attribute, we can tell Workspaces to look for child attributes inside a JSON property in the Txn.

Refactored Global mappings config
{
"$primaryApplicant": [
{
"label": "Primary",
"dataSource": "properties['Applicants']",
"properties": [
{
"label": "Type",
"dataIndex": "[0]['type']",
"type": "text"
},
{
"label": "Name",
"dataIndex": "[0]['name']",
"type": "text"
},
{
"label": "Email",
"dataIndex": "[0]['email']",
"type": "text"
},
{
"label": "SSN",
"dataIndex": "[0]['ssn']",
"type": "text"
}
]
}
],
"$SecondaryApplicant": [
{
"label": "Secondary",
"dataSource": "properties['Applicants']",
"properties": [
{
"label": "Type",
"dataIndex": "[1]['type']",
"type": "text"
},
{
"label": "Name",
"dataIndex": "[1]['name']",
"type": "text"
},
{
"label": "Email",
"dataIndex": "[1]['email']",
"type": "text"
},
{
"label": "SSN",
"dataIndex": "[1]['ssn']",
"type": "text"
}
]
}
]
}
Refactored Applicants config
{
"applicants": ["$primaryApplicant", "$secondaryApplicant"]
}

The example above demonstrates how the dataSource attribute can be used to simplify mappings configuration and group values in a single Txn property. dataSource is a new attribute supported for Applicant, Integration and Custom Card configurations.