I have below input json and my goal is to write a jolt mapper that will just remove the null from the input json and print all other values as is.
Input:
{
"accounts": {
"cust": [
{
"Num": [
"2",
"5"
],
"Type": "AB"
},
{
"Num": [
"2",
"5"
],
"Type": "CD"
},
null
]
}
}
Expected Output:
{
"accounts" : {
"cust" : [ {
"Num" : [ "2", "5" ],
"Type" : "AB"
}, {
"Num" : [ "2", "5" ],
"Type" : "CD"
}]
}
}
I tried following mapper, it removes null however it prints the values twice.
Mapper:
[
{
"operation": "shift",
"spec": {
"accounts": {
"cust": {
"*": {
"*": {
"@1": "accounts.cust"
}
}
}
}
}
}
]
Actual Output:
{
"accounts" : {
"cust" : [ {
"Num" : [ "2", "5" ],
"Type" : "AB"
}, {
"Num" : [ "2", "5" ],
"Type" : "AB"
}, {
"Num" : [ "2", "5" ],
"Type" : "CD"
}, {
"Num" : [ "2", "5" ],
"Type" : "CD"
} ]
}
}
Any help would be appreciated. Thanks!