Support Questions
Find answers, ask questions, and share your expertise

Update JSON Element w/FlowFile Attribute - Nifi

Update JSON Element w/FlowFile Attribute - Nifi

I have used EvaluateJsonPath to pull a value out of a FlowFile and put it into an attribute. Then based off the value of that attribute, I have updated the attribute to a new value. Now, how do I replace the old value in the JSON with the new value that is stored as an attribute?

I'd assume I could do this with RegEx and ReplaceText but I wasn't sure if there was a more elegant way to do it?

Thanks,

Andrew

6 REPLIES 6

Re: Update JSON Element w/FlowFile Attribute - Nifi

Super Guru

AttributestoJSON as FlowFileContent

Re: Update JSON Element w/FlowFile Attribute - Nifi

But that overwrites the entire FlowFile, right? I just want to replace that one value in the JSON (while leaving the rest of the JSON AS-IS).

8879-screen-shot-2016-10-25-at-91711-pm.png

Re: Update JSON Element w/FlowFile Attribute - Nifi

Explorer

Hi Andrew,

were you able to find a way to your question. I'm in a similar situation, have used EvaluateJson which creates the attribute but then i need to write this attribute to my json flowfile content.

Thanks!

Re: Update JSON Element w/FlowFile Attribute - Nifi

Have you looked at JoltTransformer for JSON?

Re: Update JSON Element w/FlowFile Attribute - Nifi

Rising Star

You could use UpdateAttribute processor; it has "Delete Attributes Expression" property, where you can specify the Old attribute that you want to delete; would that work ?

Re: Update JSON Element w/FlowFile Attribute - Nifi

Explorer

@Andrew Watson Hi Andrew did you find a way out for this issue