title: JQ: How To Change A Value in JSON with embedded keys
body: <p>I have the following JSON that is being returned from an AWS Secret:</p>
  <pre><code>{
      &quot;ARN&quot;: &quot;MyArn&quot;,
      &quot;Name&quot;: &quot;MySecret&quot;,
      &quot;SecretString&quot;: &quot;{\&quot;ConnectionString\&quot;:\&quot;MyConnectionString;\&quot;,\&quot;SqlCommandTimeout\&quot;:\&quot;60\&quot;,\&quot;,\&quot;ServiceAccountPrincipal\&quot;:\&quot;MyServicePrincipal\&quot;}&quot;,
      &quot;VersionStages&quot;: [
          &quot;AWSCURRENT&quot;
      ],
      &quot;CreatedDate&quot;: &quot;2022-01-13T09:08:55.442000-08:00&quot;
  }
  </code></pre>
  <p>I'd like to be able to modify the ConnectionString, the SqlCommandTimeout and the ServiceAccountPrincipal values.  For brevity, I am just showing the change to the ConnectionString.</p>
  <p>The &quot;new&quot; JSON would look like this:</p>
  <pre><code>{
      &quot;ARN&quot;: &quot;MyArn&quot;,
      &quot;Name&quot;: &quot;MySecret&quot;,
      &quot;SecretString&quot;: &quot;{\&quot;ConnectionString\&quot;:\&quot;MyNewConnectionString;\&quot;,\&quot;SqlCommandTimeout\&quot;:\&quot;60\&quot;,\&quot;,\&quot;ServiceAccountPrincipal\&quot;:\&quot;MyServicePrincipal\&quot;}&quot;,
      &quot;VersionStages&quot;: [
          &quot;AWSCURRENT&quot;
      ],
      &quot;CreatedDate&quot;: &quot;2022-01-13T09:08:55.442000-08:00&quot;
  }
  </code></pre>
  <p>However, I am not sure how to do it with JQ.</p>
  <p>What I'd like to do is have JQ modify the values for each of these fields and output the JSON object with the updated values.</p>
  <p>The problem I am having is modifying these values which are inside of embedded JSON object.  I would expect something like this to work, but it doesn't:</p>
  <pre><code>cat json.txt | jq 'SecretString.ConnectionString = &quot;MyNewConnectionString&quot;'
  </code></pre>
  <p>I am getting this error:</p>
  <pre><code>jq: error (at &lt;stdin&gt;:8): Cannot index string with string &quot;ConnectionString&quot;
  exit status 5
  </code></pre>
  <p>What I am doing wrong?</p>
  <p>Thanks</p>