For the details mentioned below, I would like to move the email.values* to payload.*.content.values (preserving the changes)
I have below Jolt –
[
{ // set values of the object keys to their accountIds
// while taking out the value of request.body.inputAccountId
"operation": "shift",
"spec": {
"*": {
"request": {
"body": {
"inputId": "inputId",
"service": "sName"
}
},
"*": {
"@": "@2,accountId.&"
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"@2,&": {
"familyRole": {
"//": "Comment: Based on Family role get the details, familyRole1=Organizer, familyRole2=Guardian, familyRole3=child",
"1|2": {
"@(2,accountId)": "payload.@(3,accountId).accountId",
"@(2,locale)": "payload.@(3,accountId).content.locale",
"@(2,onlineId)": "payload.@(3,accountId).content.values.onlineId",
"@(2,emailAddresses)": {
"*": {
"isMain": {
"true": {
"@(2,address)": "payload.@(7,accountId).destination.emailAddress"
}
}
}
},
"@(5,sName)": "payload.@(3,accountId).content.values.sName"
}
}
}
},
"inputId": {
"*": {
"@2,&": {
"onlineId": "content.cOnlineId"
}
}
}
}
}
]
For given input –
[
{
"request": {
"body": {
"inputId": "2211",
"service": "trial"
}
}
},
{
"accountId": "1234",
"role": 1,
"gender": "f",
"signinId": "[email protected]",
"onlineId": "one"
},
{
"accountId": "1122",
"role": 2,
"gender": "f",
"signinId": "[email protected]",
"onlineId": "two"
},
{
"accountId": "2211",
"role": 3,
"gender": "f",
"signinId": "[email protected]",
"onlineId": "three"
}
]
It gives me below output –
{
"content" : {
"onlineId" : "three"
},
"payload" : {
"1234" : {
"accountId" : "1234",
"content" : {
"values" : {
"onlineId" : "one",
"sName" : "trial"
}
}
},
"1122" : {
"accountId" : "1122",
"content" : {
"values" : {
"onlineId" : "two",
"sName" : "trial"
}
}
}
}
}
Expected output:
{
"payload" : {
"1234" : {
"accountId" : "1234",
"content" : {
"values" : {
"onlineId" : "one",
"cOnlineId" : "three",
"sName" : "trial",
}
}
},
"1122" : {
"accountId" : "1122",
"content" : {
"values" : {
"onlineId" : "two",
"cOnlineId" : "three",
"sName" : "trial"
}
}
}
}
}
I have applied multiple combinations in JOLT Spec but it didn’t works, Please suggest. I also referred this -/questions/76474146/how-to-insert-json-object-in-nested-json-using-jolt-spec