Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to transform a json array into a string list in NIFI

avatar
New Member

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
Guru

Hi @brian adi

You can use the SplitJson processor to get the array into individual flowfile records, then use EvaluateJsonPath to pull out the values of interest, and ReplaceText to get the content back into a CSV format. Here is a good example with screenshots showing how to do this using NiFi

https://community.hortonworks.com/articles/64069/converting-a-large-json-file-into-csv.html

As always, if you find this post useful, don't forget to accept the answer.

View solution in original post

1 REPLY 1

avatar
Guru

Hi @brian adi

You can use the SplitJson processor to get the array into individual flowfile records, then use EvaluateJsonPath to pull out the values of interest, and ReplaceText to get the content back into a CSV format. Here is a good example with screenshots showing how to do this using NiFi

https://community.hortonworks.com/articles/64069/converting-a-large-json-file-into-csv.html

As always, if you find this post useful, don't forget to accept the answer.