cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping optional arrays of objects to arrays of objects

rpatrick00
Contributor

I have an input schema that contains some optional arrays of objects in one format that I need to map to a target schema with an array of objects in another format.

The problem I am having is how to get the Mapper to map the array if it is present and ignore it if it is not. For example, my mapping table expression for one field below works fine for documents where the Address element is present but causes an error if it is missing.

jsonPath($, "$MatchUpdatePartyPayload.Address[*].NonStandardUS.Line1") 

Thanks,
Robert

12 REPLIES 12

cjhoward18
Employee
Employee

Checking the ‘Null-safe access’ property in the mapper will allow for accessing a null field and will give you a null value instead, which can be dealt with downstream possibly?

rpatrick00
Contributor

While that gets rid of the error, it just creates more problems downstream with my custom snap’s validation code. Is there some other way to accomplish this sort of mapping?

What would you like the value to be when it is not present?

rpatrick00
Contributor

I would like the mapper to simply ignore the entry and move to the next one…

If I have 10 lines in my mapping table and the input field(s) are not present for 5 of those lines, then the mapper should only map the 5 lines that it has input data for…