How to Merge the original data with API response data based on the API response values and the array of json indexes in Apache NiFi
Orginal data:
{
"data": [
{
"id": "1234569",
"Date": "2022-08-22"
},
{
"id": "1234567",
"Date": "2022-08-22"
},
{
"id": "34567",
"Date": "2022-08-22"
}
]
}
API Response:
[ {
"Record 2" : "Invalid values for emp info"
}, {
"Record 3" : "Invalid values for emp info"
} ]
Where Record 1,Record 2,Record 3 is array of json object index. Here we have three records in orginal data, Record 1 passed successfully and remaining two failed and due to that in response we are getting Record 2 and Record 3
i.e. if index of orginal data = value of Record (for example original data's index 1 is passed successfully so it should not merge. In orginal Response Index 2 failed, so it should merge with Record 2 and so on.. ) then final output should look like below:
{
"data": [
{
"id": "1234567",
"Date": "2022-08-22",
"Record 2" : "Invalid values for emp info"
},
{
"id": "34567",
"Date": "2022-08-22",
"Record 3" : "Invalid values for emp info"
}
]
}
How can I do that? Please help.

