Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NIFI: get value from json

i have a queryCassandra which generate json like this one:

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

Now, i want to get from this all the term 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 !

like image 657
Remis07 Avatar asked Sep 16 '25 00:09

Remis07


1 Answers

You can easily get those values by using following ways.

GetFile-->EvaluateJsonPath-->PutFile

In get file you have to specify location of json file.

In EvaluateJsonPath configure like following properties.,

Destination:flowfile-attribute
Return Type:json
input.term1:$.results.[0].term           //To get term
input.term2:$.results.[1].term

At the result of Evaluate json you have two attributes in which having those values.

Result attributes:

input.term1: term1

input.term2: term2

Above code works for me,so feel free to upvote/accept as answer.

like image 158
Mister X Avatar answered Sep 17 '25 19:09

Mister X