Support Questions

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

how i extract attribute from json file using nifi

avatar
Rising Star

I use gethttp processor to stream data using http request, so I need to get attribute from file json that I get from the first request and use it for another request, how I can do this with the existing nife processor.any help is appreciated

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

avatar
New Contributor

hi is there any way to extract the attributes without nifi ! i mean , i need to extract an attribute from a collection of tweet i already have !

avatar
New Contributor

Hi, We have extracted the required fields from Json file as below.

It is not with only one processor. It is with two processors.

1. EvaluateJsonPath : What ever the configurations above mentioned are correct. This processor will validate whether this field exists or not. If not, then it will show that filed value as null.

2. AttributesToJSON : In the Attributes list property, give what ever the fields you want to pull (with comma separated) from the fields added in the EvaluateJsonPath processor.

[say you have added field1 to 6 in EvaluateJsonPath and then you want only field 1,3,4. Then give field1,field3,field4 in the Attributes list in the AttributesToJSON processor.]

Hope this helps you.

avatar
Explorer

Hello, I have a json flow file as follows:

Hashem1980_2-1658342808789.png

 

I used: EvaluateJsonPath:

Hashem1980_0-1658342535446.png

But the result is: < Empty string set>

Hashem1980_1-1658342610303.png

Thanks for your help and guide.

avatar
New Contributor

You are using an array, this is why you got null values. You have 2 options:

  1. Change the expressions to $[0].ARRIVAL_DATE and $[0].BOOK_ID, and it will work
  2. Read the file and split the array using the SplitJson processor - set JsonPath expression to: $, and connect the SplitJson processor to your EvaluateJsonPath processor and it should work.