Requirement - I want to remove null values from the transformed Json using Jolt spec.
Input -
{
"parentResponse": {
"parentHierarchy": [
{
"hierarchyType": "MAINTAINANCE",
"parents": [
{
"level": "Test",
"levelCode": "BO",
"operationalId": "OP"
},
{
"level": "Test",
"levelCode": "BO",
"operationalId": "OP"
},
{
"level": "Contract",
"levelCode": "CO",
"operationalId": "DP"
}
]
}
]
}
}
Jolt Spec - If hierarchyType = "MAINTAINANCE" && parents[].levelCode = "CO" then copy the parents[].operationalId to the output
[
{
"operation": "shift",
"spec": {
"parentResponse": {
"parentHierarchy": {
"*": {
"hierarchyType": {
"MAINTAINANCE": {
"@(2,parents)": {
"*": {
"levelCode": {
"CO": {
"@(2,operationalId)": "request.common.hierarchyData.hrchyArray[&3].hrchyEntityId"
}
}
}
}
}
}
}
}
}
}
}
]
Actual Output -
{
"request" : {
"common" : {
"hierarchyData" : {
"hrchyArray" : [ null, null, {
"hrchyEntityId" : "DP"
} ]
}
}
}
}
Expected Output -
{
"request" : {
"common" : {
"hierarchyData" : {
"hrchyArray" : [{
"hrchyEntityId" : "DP"
} ]
}
}
}
}
