JSON to Mapper

When I’ trying to map data from a JSON getting an error saying “The field not found in JSON Object”.
But the field is existing in the JSON.

Can anyone suggest me how can I overcome this issue? Adding the pipeline for more exposure.

CostCenter_2019_06_18.slp (12.9 KB)

Some of the elements of the array, $['soapenv:Body'].searchResponse['platformCore:searchResult']['platformCore:recordList']['platformCore:record']['tranGeneral:lineList']['tranGeneral:line'][*], did not contain a department. One way to handle this would be to add a default value for the department prior to reading the values.

Here’s the expression I used to check if it’s there, otherwise return a default value. I just used null here, but you can adjust to your taste.

$.hasPath('tranGeneral:department') ? $['tranGeneral:department'] : {'@internalId': null}

Then use the same approach in the downstream mapper and read all the values. Since all elements now contain a department, it doesn’t choke in the same way.

Your example with my addition.

CostCenter_with_defaults_2019_06_18.slp (14.1 KB)

1 Like