title: NiFi: Merge an Attribute into the Flow-file's JSON Content (without overwriting the entire flowfile)
body: <p>I have a flow that creates some new attributes / content. I want to take an attribute from the flow files, and add it into the JSON content of the file. </p>
  
  <p>I can use <code>AttributesToJSON</code>, but that just overwrites the file content. </p>
  
  <p>A sample of my flow is here: </p>
  
  <p><a href="https://i.stack.imgur.com/NIedk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NIedk.png" alt="enter image description here"></a></p>
  
  <p>The <code>UpdateAttribute</code> adds current time to the attribute list, and then the <code>AttributestoJSON</code> adds an attribute to the actual JSON, but it also <strong>overwrites</strong> the entire flow file content. I've tried to remedy this with <code>MergeRecord</code>, but I can't the two files to merge back together (using <code>CurrentTime</code> as a Correlation Attribute Name). </p>
  
  <p>Is there a better to go about this? The <code>MergeRecord</code> just comes up with an error. (Also not sure how to configure the RecordReader/Writer, because I want to keep everything in JSON). </p>