You are here:
Change the Hierarchical Level of a List
If a list is defined at the wrong level of a JSON node hierarchy, you can use an Omnistudio Data Mapper Transform to change the level at which the list is defined. This approach only works for a short list with a known number of items.
This example describes how to create a Data Mapper Transform that converts a list defined
at Contacts:Name to a list defined at Contacts.
Create Settings
| Field | value | notes |
|---|---|---|
| Interface Type | Transform | |
| Input Type | JSON | In this example, the input is provided as JSON and not pulled from another source. |
| Output Type | JSON |
Transform Settings
In the Manage Input/Output Type window, use these values.
- Input JSON
-
{ "Contacts": { "Name": [ { "First": "John", "Last": "Doe" }, { "First": "June", "Last": "Doe" } ] } } - Expected JSON Ouput
-
{ "Contacts": { "Name": [ { "First": "John", "Last": "Doe" }, { "First": "June", "Last": "Doe" } ] } }
Click Quick Match, and in the Quick Match dialog, click Auto Match and save.
To add list position indexes, edit the mappings.
| Field | value | notes |
|---|---|---|
| Input JSON Path | Contacts:Name|1:First |
|
| Output JSON Path | Contacts|1:Name:First |
Click Quick Match again, click Auto Match and save. Edit the new mappings to add list position indexes.
| Field | value | notes |
|---|---|---|
| Input JSON Path | Contacts:Name|2:First |
|
| Output JSON Path | Contacts|2:Name:First |
Transformation Preview
In Preview, the input is similar to the sample JSON.
{
"Contacts": {
"Name": [
{
"First": "John",
"Last": "Doe"
},
{
"First": "June",
"Last": "Doe"
}
]
}
}
After you execute the sample Data Mapper in Preview, the input map is transformed into a list, as indicated by the square brackets.
{
"Contacts": [
{
"Name": {
"First": "John",
"Last": "Doe"
}
},
{
"Name": {
"First": "June",
"Last": "Doe"
}
}
]
}

