Skip to main content
mohdriyaz
Gold ⭐️
March 30, 2024
Solved

How to evalute Attribute (Json format)

How to Evaluate attribute (output of Invoke Http which is in JSON format)

mohdriyaz_0-1711781753325.png

This attribute value contain a Json in the following format 

 {

    location : { FileSource :  "X" ,  URL : "Y"}

} 

From this attribute value (Json), I need to extract File Source and URL and put it into another attribute with the same name.

Note : Flow file Content should remain as it is.

Any Pointer ..??

mohdriyaz
mohdriyazAnswer
Gold ⭐️
April 4, 2024

I got the Solution.

Use UpdateAttribute processor and Expression Language. 

mohdriyaz_0-1712214695029.png

Here "SignedURL" is the attribute (containing complex Json) and from that I fetch particular Key value using Expression Language (JSONPATH) 

 

3 replies

saquibsk
Gold ⭐️⭐️
April 2, 2024

Hi @mohdriyaz,

You can achive this by using following steps.

 

saquibsk_0-1712023469788.png

 

Step1: In GenertateFlow I took your input

 

saquibsk_1-1712023515147.png

Step2: Use EvaluateJsonPath and set the Destination as Flowfile-attribute and write the JSON Path

saquibsk_2-1712023607772.png

 

Step3: Use UpdateAttribute in case of further modification.

output:

saquibsk_3-1712023657706.png

 

------------

If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Translate
Shakib M.
mohdriyaz
mohdriyazAuthor
Gold ⭐️
April 4, 2024

@saquibsk 

Thanks for Reply. 

Solution you have provided will work with content of flow file and not with the attribute.  EvaluateJsonPath is use to evaluate the JSON present in flow file content. 

In my case , I have JSON present as attribute and not as content of flow file.

Translate
mohdriyaz
mohdriyazAuthorAnswer
Gold ⭐️
April 4, 2024

I got the Solution.

Use UpdateAttribute processor and Expression Language. 

mohdriyaz_0-1712214695029.png

Here "SignedURL" is the attribute (containing complex Json) and from that I fetch particular Key value using Expression Language (JSONPATH) 

 

Translate