I have questions on this attached flow. Here my goal is not to overwrite the original flowfile. 1. There is ReplaceText before SplitJson. As we can do SplitJson only on flowfile, I did ReplaceText. How can i do SplitJson on an attribute instead of on flowfile? 2. There is EvaludateJsonPath after InvokeHTTP. I want to store response of InvokeHTTP to an attribute of an existing flowfile. If I store, how can I have EvaludateJsonPath on that stored attribute? I thought EvaludateJsonPath is only on flowfile, not on attribute. 3. There is ReplaceText before MergeContent. ReplaceText is there because I can merge only flowfile, not attributes. How can I merge attributes with/without MergeContent?screenshot-2017-03-21-144721.png
Hi @Srini Nalluri. I am not 100% sure if i have understood your question correctly, but are you mostly interested in manipulating the attributes of the data you are passing through as flowfiles, rather than the data itself? If so, Have you seen the NiFi Expression Language guide here https://nifi.apache.org/docs.html under General -> Expression Language Guide? It describes the ways in which we can manipulate attributes.
For 1, you could use an UpdateAttribute processor and use the jsonPath function to pull out various individual values from your JSON attribute and assign them to new attributes. There are some good examples in the language guide:
For 2, you could set the Put Response Body In Attribute property in your InvokeHTTP processor to store it as an attribute, and then use the jsonPath expression language function in an UpdateAttribute processor to evaluate it.
For 3, in an UpdateAttribute processor you could use the append/prepend functions to merge or concatenate two attribute values together, e.g. (where attribute1 and attribute 2 have previously been set):
Or, there is an AttributesToJSON processor https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.AttributesToJS... if you need to get your new attributes back into JSON format.
Hope it helps