Support Questions

Find answers, ask questions, and share your expertise

How to store json object in a variable using apache nifi?

avatar
Contributor

 

The following flowfile is the response of an "InvokeHttp":

 

[

  {"data1":"[{....},{...},{....}]","info":"data-from_site"},

  {"data2":"[{....},{...},{....}]","info":"data-from_site"},

  {"data3":"[{....},{...},{....}]","info":"data-from_site"}

]

 

I did a "SplitJson", i got each json record as a single flowfile

flowfile 1:

 

  {"data1":"[{....},{...},{....}]","info":"data-from_site"}

 

flowfile 2:

 

  {"data2":"[{....},{...},{....}]","info":"data-from_site"}

 

flowfile 3:

 

  {"data3":"[{....},{...},{....}]","info":"data-from_site"}

 

I want to store each json record in each flowfile in a variable like that:

 

  variable1 = "{"data1":"[{....},{...},{....}]","info":"data-from_site"}"

  variable2 = "{"data2":"[{....},{...},{....}]","info":"data-from_site"}"

  variable3 = "{"data3":"[{....},{...},{....}]","info":"data-from_site"}"

 

can someone show me how to store the json record in a variable !

5 REPLIES 5

avatar
Super Guru

This is not efficient and will use a lot of heap depending on how big the list and the json array. Can you explain more what are you trying to do  and why you want to create different variable for each json flowfile? Maybe there is a better way.

avatar
Contributor

To store each json flowfile as a single row in Postgres. 

avatar
Super Guru

avatar
Contributor

The solution you suggested there wasn't helpful. 

avatar
Super Guru

I apologize for that, I hope someone else step in and help you with better solution. May I just know why it did not help?