Using JOLT to remove field with null value
Hi,
I have a json data as follow.
INPUT :
{
"vlineid" : "9PIA",
"type" : "M",
"catg" : "C",
"nhhigh" : 100.0,
"nhigh" : 50.0,
"nlow" : null,
"nllow" : null,
"uom" : "sec",
"vsectionid" : "PEPO60",
"vparamdesc" : "CYCLE TIME",
"vpartid" : "-",
"vflgipc" : "IPC02",
"vwctid" : "P9PIA0",
"vmachineid" : "IMM04",
"vparam" : "CYCLE-TIME",
"nvalue" : 0.0,
"t" : 1722833150160,
"vcrea" : "NIFI",
"vmodi" : "NIFI",
"dmodi" : "2024-08-05 11:49:17",
"dcrea" : "2024-08-05 11:49:17",
"t_epoch" : 1
}
I tried to remove the null field with this JOLT Specification
JOLT :
[
{
"operation": "shift",
"spec": {
"*": "temp.&"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
},
{
"operation": "shift",
"spec": {
"temp": ""
}
},
{
"operation": "remove",
"spec": {
"temp": ""
}
}
]
OUTPUT :
{
"vlineid" : "9PIA",
"type" : "M",
"catg" : "C",
"nhhigh" : 100.0,
"nhigh" : 50.0,
"uom" : "sec",
"vsectionid" : "PEPO60",
"vparamdesc" : "CYCLE TIME",
"vpartid" : "-",
"vwctid" : "P9PIA0",
"vmachineid" : "IMM04",
"vparam" : "CYCLE-TIME",
"nvalue" : 0.0,
"t" : 1722833150160,
"vcrea" : "NIFI",
"vmodi" : "NIFI",
"dmodi" : "2024-08-05 11:49:17",
"dcrea" : "2024-08-05 11:49:17",
"t_epoch" : 1
}
The JOLT did remove the nlow and nllow field, but also removed the vflgipc when the vflgipc value is not null, and sometimes even the nlow or nllow field was not removed, even though it has a null value. I'm new with JOLT and Record Processing, can someone help me?
Thank You,
Regards,
Muhammad Adhitya Dharamawan


