Support Questions

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

How to transform a json array into a string list with nifi

avatar

Hello,

i have a queryCassandra which generate a json like this one:

{"results":[{"term":"term1"},{"term":"term2"}..]} 

Now, i want to get from this all the terms values separated by some separator in string format;

ex : term1,term2,term3

So i can pass this list as a string parameter for a java main program which i've alreat set.

(i only need the transofrmation, not the java program execution) Thank you !

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
5 REPLIES 5

avatar
New Contributor

first you need to validate JSON data , you can use this tool JSON Formatter and JSON Validator

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

thanks @kkawamura! a last question, how can i get the flowfile generated as ex : term1,term2,term3 as a parameter in the next processor?

avatar

You mean how to map the attribute value (term1,term2,term3) to FlowFile content? If so, I'd use ReplaceText processor, set Replacement Value as "${attribute-name}" and Replacement Strategy as "Always Replace".

avatar
New Contributor

In my case I have to fetch a particular key value from a json array. I was trying to do $.[key] but it just splits the array into separate json files. Is there any solution for this ? I wanted the split array as {"test1", "test2"}

Jsonarray example: [{"key":"test1", "name":"testName"}, {"key":"test2", "name":"testName2"}]