Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

filter json - routeonattribute - nifi


filter json - routeonattribute - nifi

Super Guru

I have following json to parse:


<some attributes with their values>,

"Events":{ "someattribute":"somevalue", "values":[ { "attribute":"<values>", <more attributes> "Description":"valuetomatch", <lot more attributes>, "MethodType":"GET"


{ "attribute":"<values>", <more attributes> "Description":"value_not_to_match", <lot more attributes>, "MethodType":"GET"




<more attributes>

} //end of json record

If you see sample record, their is an attribute called "Description" in my "Events.values[*]" array. I want the json but don't need all the elements of "Events.values[*]" array. I only need values where description is set to "valuetomatch".

I read the file, then I send it to evaluatejsonpath processor. there I create a new flow file attribute called events.description. here is how it looks


the I pass this to "routeOnAttribute" processor where I say how to filter (see second screen shot). My question is how do I discard the rejected values from the array. I don't want to reject the whole json record. I just want to drop some values from the array.


Re: filter json - routeonattribute - nifi

Expert Contributor

I would change the definition of events.description to something like, $.Events.values.Description. Next, as you have done, I would use a RouteOnAttribute events.description where values are equal to valuetomatch. Finally, use an AttributesToJSON processor to use only the attributes that you want.

Re: filter json - routeonattribute - nifi


I want append values to some of empty attribute's values in one from processor to existing processor of JSON data .Please can u assist on this asap.




Don't have an account?
Coming from Hortonworks? Activate your account here