Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi processor - route json array into multiple json arrays based on condition on json filed/attribute

avatar
Rising Star

Is there any Nifi processor to route mulitple json arrays(by splitting json array based on field/attribute condition) to multiple processor based on json field condition .

ex : assume [{a:1},{a:1},{a:2},{a:2}] is jsonarray , there is a requiremnt to route a=1 contained json files are send to another processor as array . and a=2 json array to another processor

1 ACCEPTED SOLUTION

avatar
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
7 REPLIES 7

avatar
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar

Another solution would be:

SplitJson -> EvaluateJsonPath (store a on attribute) -> RouteOnAttribute -> MergeContent

But if the desired output is JSON array, using EvaluateJsonPath is simpler.

avatar
Rising Star

thank you . is it possible add 2 condition for content like a=='1 ' or a=='2' (or) a=='1' and i=='ss' . Thanks in advance

avatar
Rising Star

what is this expression languauge : $.[?(@.a...] , is it jave regex ? how can we use 2 values filter OR or AND for content filed ?? like a==1 or a==2 .

avatar

Hello, sorry for the delay. The language is JSONPath. JSONPath itself has filtering capabilities. Many examples can be found on this page. https://github.com/jayway/JsonPath

avatar
Explorer

I have some sort of the same scenario. But I have to route out on department value, like department="IT" route to some other flow and for department="DB" route to another flow.

 

For that, I have written out expression as  $.[?(@.department=="DB")]. But this doesn't work. Please suggest for the above scenario.

 

And also if we have to apply some conditions like route data for a>10 like that.

avatar
Contributor

how to append values for empty flowfile attributes for JSON format data. i.e suppose i have 40 columns with JSON data consuming from kafka queue and i have values for 25 fields only and remaining 15 fields, i don't have values .So i put the json into EvaluateJsonPath processor and converted into flowfile attributes ..From some other processor i am getting values for those empty attributes so i need to append/fill the empty attributes with the values with orginal json file.

Can you please suggest how to use it?

thanks