i need to remove the duplicates in json message using jolt framework with insuredId and copy the unique insuredId and insuredName to namecode and name respectively,i have acheived removing the duplicates with the insuredId but i dont know how to copy the corresponding Insured name along with it.
Input:
[
{
"aircraftId": "ILTA",
"aircraftTypeCode": "",
"insuredId": "12020671",
"insuredName": "Samuel Antony",
"policyReference": "20081238",
"uwy": "2017"
},
{
"aircraftId": "ILTA",
"aircraftTypeCode": "",
"insuredId": "12020671",
"insuredName": "Samuel Antony",
"policyReference": "20081238",
"uwy": "2017"
},
{
"aircraftId": "ADE",
"aircraftTypeCode": "",
"insuredId": "12018832",
"insuredName": "Mark henry",
"policyReference": "20082780",
"uwy": "2017"
}
]
Jolt Spec :
[
{
"operation": "shift",
"spec": {
"*": {
"insuredId": {
"*": "ids.&[]"
}
}
}
},
{
"operation": "shift",
"spec": {
"ids": {
"*": {
"$": "[#2].nameCode"
}
}
}
}
]
Actual output :
[
{
"nameCode": "12020671"
},
{
"nameCode": "12018832"
}
]
Expected Output:
[
{
"nameCode": "12020671",
"name":"Samuel Antony"
},
{
"nameCode": "12018832",
"name":"Mark henry"
}
]
Updated Spec (needs to be validated):
[
{
"operation": "shift",
"spec": {
"*": {
"insuredId": {
"*": "ids.&[]"
},
"insuredName": {
"*": "insuredNames.&[]"
}
}
}
},
{
"operation": "shift",
"spec": {
"ids": {
"*": {
"$": "[#2].nameCode"
}
},
"insuredNames": {
"*": {
"$": "[#2].name"
}
}
}
}
]