Can someone help with Jolt spec for the below requirement? Input:
{
"individuals": [
{
"individual": {
"LastName": "Ind1-LastName",
"firstName": "Ind1-FirstName"
}
},
{
"individual": {}
}
]
}
Expected output:
{
"linkedIndividuals": [
{
"individual": {
"LastName": "Ind1-LastName",
"firstName": "Ind1-FirstName"
}
}
]
}
CodePudding user response:
You can dive deep upto the innermost node in order to encounter the key name without a value, then add the respective replacement symbols(&3.[&2].&1.&
) consecutively to construct the JSON body again by using such a shift transformation spec such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"*": "linked&3.[&2].&1.&"
}
}
}
}
}
]