Some source systems do not use a flat schema, and their fields can contain sub-fields. Mapping rule language provides operators on the source side that pull values from nested data.
For example, a source system can emit records with a nested JSON structure, such as the
demographics field in the following record:
{
"id": "0b71bec6-5232-49e1-b99b-98e612d2d24d",
"first_name": "Brian",
"middle_name": "D",
"last_name": "Lym",
"display_name": "Brian Lym",
...
"demographics": {
"birthday": "2004-04-12",
...
}
}Object index operator
The object index operator {} accesses a field nested in a JSON
object. The following rule assigns the birthday field from the
demographics object:
let idautoPersonBirthdate = demographics{"birthday"}
Find operator
The Find operator searches an array of JSON objects and returns the first object that
matches the supplied predicate. Combine Find with the object index operator to
return a specific value.
The following rule uses the orgs array to find the
sourcedId of the org with a type of school:
let idautoPersonLocCode = orgs.find("type", "school"){"sourcedId"}