Reputation: 1006
SplitJson processor is throwing warning message when the json path does not exists. We wants to ignore this messages on our prod environment.
Example:
{"Payload":{"ProfileScores":{"scoreList":[{"Profile":"Value 1","MatchedPatternId":"Value 2"}]}}}
Now based on above json, if we use the SplitJson processor with $.Payload.ProfileScores.scoreList[*] as JsonPath Expression then everything works fine because the path is accessible.
BUT
in some cases ProfileScores object is null like this: {"Payload":{"ProfileScores":""}}.
Now as ProfileScores object is empty or null, then SplitJson throws the warning message for that particular flowfile.
Now we want to remove those warning message as it is clogging up the logs area in prod environment.
Is there any way to check if $.Payload.ProfileScores is null/empty or exists or not before sending the flowfile to SplitJson processor?
Solutions i have tried:
Upvotes: 0
Views: 529
Reputation: 28634
here is an expression you could use:
$.Payload[?(@.ProfileScores nin [null,''])].ProfileScores.scoreList[*]
?(expression)
- where
@
- current element
A nin []
- A not in array on the right
more explanation and examples here: https://github.com/json-path/JsonPath#path-examples
i used your file from question and this jsonpath works fine in nifi 1.16.3
Upvotes: 0