title: Merging two JSON objects with jq
body: <p>I have two json files, each containing one simple object, for example:</p>
  
  <p><em>file1</em></p>
  
  <pre><code>{
      "key1": "value1",
      "key2": "value2"
  }
  </code></pre>
  
  <p><em>file2</em></p>
  
  <pre><code>{
      "key1": "valueA",
      "key3": "valueB"
  }
  </code></pre>
  
  <p>I need to combine these two using jq so that I end up with one object that contains all of the keys from both objects. If there are common keys, I need the values of from second object being used.</p>
  
  <p>I'm struggling to get the right expression to use. I thought that something as simple as</p>
  
  <pre><code>jq '. * .' file1 file2
  </code></pre>
  
  <p>should give me what I want, however this results in a non-json output:</p>
  
  <pre><code>{
      "key1": "value1",
      "key2": "value2"
  }
  {
      "key1": "valueA",
      "key3": "valueB"
  }
  </code></pre>
  
  <p>The same exact thing happens if I use <code>jq '. + .' file1 file2</code>.</p>
  
  <p>How can I combine these two objects?</p>