Support Questions

Find answers, ask questions, and share your expertise

Add attribute (String value) to an array in flow file.

New Contributor



I have an attribute of type string and my flow file has an array of strings. I want to add attribute into the array of strings in flow file.


Please help me with the process.


Thank you


Expert Contributor


For me your question is to abstract, sorry. Could you show some of your data?

Are we talking about JSON-array?
If so and you are already using NiFi 1.10.0 there are some new options in expression language to manipulate JSON.

New Contributor

This is my JSON in flow file content

"linkedData" : [ ],
"comid" : "C3XXXXXXXXXXA-aidan-16802451"

I have an attribute 

callid : C3XXXXXXXXXX-XXXX-16802451
I want attribute callid value into linkedData array in JSON of flow file

Expert Contributor

Maybe you want to try this way. Worked on 1.10.0


New Contributor

Thank so much for the reply.


I tried the flow, but i am see an exception "Unexpected token 'jsonPathAdd'". I am using nifi 2.11.

org.apache.nifi.processor.exception.ProcessException: Unable to evaluate new value for attribute 'FF_CONTENT': org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageException: Invalid Expression: ${FF_CONTENT:jsonPathAdd('$linkedData',${callid})} due to Unexpected token 'jsonPathAdd' at line 1, column 13.

Expert Contributor

NiFi 2.11 ? I must have missed something...

Let's assume it is 1.11.0 then the used function should be available.


I think there is a typo in your Expression Language.

${FF_CONTENT:jsonPathAdd('$.linkedData', ${callid})}

There has to be a dot between $ and linkedData.

New Contributor

Apologies I gave wrong version.nifi 1.9.2


Also I tried correcting syntax


Invalid Expression: ${FF_CONTENT:jsonPathAdd('$.linkedData',${callid})} due to Unexpected token 'jsonPathAdd'



Expert Contributor

Oh, too bad, this options for manipulating JSON with Expression Language are - as far as I know - not available before 1.10.0.


When the JSON-format is really stabil maybe this will work for you.

UpdateAttribute ==> ${FF_CONTENT:substringBefore('['):append('["'):append(${callid}):append('"]'):append(${FF_CONTENT:substringAfter(']')})}


It is not "elegant" but I haven't got another idea, sorry.

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