How can I transform(remove in this case) flowfile if one of the fields of the object is null using JoltTransformJson processor in nifi
here below is my data.
emp.json:
[
{
"Name" : "john Smith",
"DOB" : "2000-07-14",
"Salary" : 16000.0
},
{
"Name" : "Sara Jacob",
"DOB" : "2000-07-14",
"Salary" : 12000.0
},
{
"Name" : "Peter John",
"DOB" : null,
"Salary" : 20000.0
},
{
"Name" : "Lia Poul",
"DOB" : "2000-07-14",
"Salary" : 18000.0
}
]
I used SplitJSON
processor to split the JSON File into multiple -separate FlowFiles and i connected the downstream with the JoltTransformJson
processor. Next, I configured JoltTransformJson as below:
Jolt Transformation DSL: chain
Jolt Specification:
[
{
"operation": "remove",
"spec": {
"rowsToRemove": {
"*": {
"DOB": {
"$null": ""
}
}
}
}
}
]
But this expression only removed the DOB field, not the whole object and Flowfile.
2
Answers
Yes you can use
JoltTransformJSON
processor with the following transformation specs which contain notNull function that pricipally resolves the issue such asthe demo on the site http://jolt-demo.appspot.com/ is