title: Replace array element within JSON hash with content from other file
body: <p>I have got a configuration with content to be exchanged with snippets from separate file. How would I neatly achieve this?</p>
  
  <p>Config file might look like:</p>
  
  <pre><code># config file
  {
      "keep": "whatever type of value",
      "manipulate": [
          {
              "foo": "bar",
              "cat": {
                  "color": "grey"
              },
              "type": "keep",
              "detail": "keep whole array element"
          },
          {
              "stuff": "obsolete",
              "more_stuff": "obsolete",
              "type": "replace",
              "detail": "replace whole array element with content from separate file"
          },
          {
              "foz": "baz",
              "dog": {
                  "color": "brown"
              },
              "type": "keep",
              "detail": "keep whole array element"
          },
  
      ],
      "also_keep": "whatever type of value"
  }
  </code></pre>
  
  <p>The content (coming <strong>from separate file</strong>) to be inserted as a replacement of <em>obsolete</em> array element:</p>
  
  <pre><code># replacement
  {
      "stuff": "i want that",
      "fancy": "very",
      "type": "new"
  }
  </code></pre>
  
  <p>The desired result should look like:</p>
  
  <pre><code># result
  {
      "keep": "whatever kind of value",
      "manipulate": [
          {
              "foo": "bar",
              "cat": {
                  "color": "grey"
              },
              "type": "keep",
              "detail": "keep whole array element"
          },
          {
              "stuff": "i want that",
              "fancy": "very",
              "type": "new"
          },
          {
              "foz": "baz",
              "dog": {
                  "color": "brown"
              },
              "type": "keep",
              "detail": "keep whole array element"
          },
  
      ],
      "also_keep": "whatever kind of value",
  }
  </code></pre>
  
  <p>Requirements:</p>
  
  <ul>
  <li>Content replacement needs to be done based on <code>type</code> key's value.</li>
  <li>Preferably use <code>jq</code> and common bash/linux tools.</li>
  <li>Array element ordering should stay same</li>
  </ul>