title: How can I replace a null value in a json document by a specific value with jq?
body: <p>I have a json file that contains <code>null</code>s as values for some keys, which I would like to replace with some specific value.</p>
  
  <p>Given this input:</p>
  
  <pre><code>{
    "id": null,
    "rows": [
      {
        "panels": [
          {
            "title": "Panel1",
            "datasource": null
          },
          {
            "title": "Panel2",
            "datasource": null
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>I would like to have</p>
  
  <pre><code>{
    "id": null,
    "rows": [
      {
        "panels": [
          {
            "title": "Panel1",
            "datasource": "mydb"
          },
          {
            "title": "Panel2",
            "datasource": "mydb"
          }
          ]
       }
    ]
  }
  </code></pre>
  
  <p>What I currently use is</p>
  
  <pre><code>sed 's/"datasource": null/"datasource": "mydb"/'
  </code></pre>
  
  <p>This produces the output I need, but I keep thinking that it is a shame to use <code>sed</code> for this job, when there are tools like <code>jq</code> that can work on JSON in a much better way.</p>