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

attributesToJSON returns attribute as string instead of json


Output of attributesToJson is:




when it should be




As you can see the revision property is encoded as string when it should be json.

How can I resolve this?


Master Guru



NiFi stores all FlowFile attributes as strings.
And I am guessing you stored json in a FlowFile Attribute named revision.


The AttributestoJson processor builds a flat json from those attribute strings, so it is going to wrap the 


in quotes and escape the embedded quotes within that string with a backslash.

You could cleanup the produce json after it is built to remove the unwanted quotes and escape characters on the other quotes.  How you do this depends on whether your AttributesToJson processor is writing the output to a FlowFile Attribute or to the FlowFile's content.

If writing to a FlowFile's Attribute, you would use UpdateAttribute processor.
If writing to the FlowFile's content, you would use multiple ReplaceText processors.


Hope this helps,





After attributestoJSON which wrote the attributes to file-content, I used replaceText and it worked. thanks for the help!

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.