title: JSON and jq updating multiple values
body: <p>Hi I am trying to perform a calculation within a single "jq" command but I cannot workout how to reference the new values.</p>
  
  <p>Original JSON</p>
  
  <pre><code>{
    "Status": "Down",
    "StatusID": "75328241",
    "Start": "2017-03-17 15:06:40",
    "End": "2017-03-17 15:08:37",
    "Period": "1 Minutes "
  }
  </code></pre>
  
  <p>My goal is to convert the start and end times to epoch and workout the duration in seconds. Then output the same object with the new values.</p>
  
  <p>When I do this</p>
  
  <pre><code>echo $J_SON | jq '.Start |= (strptime("%Y-%m-%d %H:%M:%S") | mktime),.End |= (strptime("%Y-%m-%d %H:%M:%S") | mktime)'
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>{
    "Status": "Down",
    "StatusID": "75328241",
    "Start": 1489763200,
    "End": "2017-03-17 15:08:37",
    "Period": "1 Minutes "
  }
  {
    "Status": "Down",
    "StatusID": "75328241",
    "Start": "2017-03-17 15:06:40",
    "End": 1489763317,
    "Period": "1 Minutes "
  }
  </code></pre>
  
  <p>Which makes sense, the manual says that this is default behaviour. </p>
  
  <blockquote>
    <p>Assignment works a little differently in jq than in most programming
    languages. jq doesn’t distinguish between references to and copies of
    something - two objects or arrays are either equal or not equal,
    without any further notion of being “the same object” or “not the same
    object”.</p>
    
    <p>If an object has two fields which are arrays, .foo and .bar, and you
    append something to .foo, then .bar will not get bigger, even if
    you’ve previously set .bar = .foo. If you’re used to programming in
    languages like Python, Java, Ruby, Javascript, etc. then you can think
    of it as though jq does a full deep copy of every object before it
    does the assignment (for performance it doesn’t actually do that, but
    that’s the general idea).</p>
  </blockquote>
  
  <p>But I would then like to output the values in epoch as well as seconds.</p>
  
  <p>I managed to successfully get the duration like this:</p>
  
  <pre><code>echo $J_SON | jq '.Period = ((.End | strptime("%Y-%m-%d %H:%M:%S") | mktime)-(.Start | strptime("%Y-%m-%d %H:%M:%S") | mktime))'
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>{
    "Status": "Down",
    "StatusID": "75328241",
    "Start": "2017-03-17 15:06:40",
    "End": "2017-03-17 15:08:37",
    "Period": 117
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>I can get the individual values of each variables but not sure how to then concatenate them all in a single output object.</p>