title: extracting json inside json with jq
body: <p>I often find myself wanting to parse json with the <code>jq</code> command, but one of the values inside the json is an escaped string of json.</p>
  <p>e.g. if I generate data with python like this:</p>
  <pre><code>import json
  inner = {'a': 'b'}
  outer = {'x': json.dumps(inner)}
  json.dumps(outer)
  </code></pre>
  <p>I get:</p>
  <pre><code>{&quot;x&quot;: &quot;{\&quot;a\&quot;: \&quot;b\&quot;}&quot;}
  </code></pre>
  <p>How do I get <code>&quot;b&quot;</code> using the <code>jq</code> command?</p>
  <pre><code>$ echo '{&quot;x&quot;: &quot;{\&quot;a\&quot;: \&quot;b\&quot;}&quot;}' | jq .x
  &quot;{\&quot;a\&quot;: \&quot;b\&quot;}&quot;
  </code></pre>
  <p>Ok, that's the first step.
  But the result isn't a json dictionary. It's a string that needs to be escaped and parsed into json.</p>
  <p><code>jq .x.a</code> throws an error: <code>jq: error (at &lt;stdin&gt;:1): Cannot index string with string &quot;a&quot;</code></p>
  <p>Is there an argument I can add to <code>jq</code> to chain together two <code>jq</code> steps?
  Or is there another command I can use instead?</p>
  <p>e.g.</p>
  <pre><code>echo '{&quot;x&quot;: &quot;{\&quot;a\&quot;: \&quot;b\&quot;}&quot;}' | jq .x | jq --some-argument .a
  </code></pre>
  <p>or</p>
  <pre><code>echo '{&quot;x&quot;: &quot;{\&quot;a\&quot;: \&quot;b\&quot;}&quot;}' | jq .x | something-else | jq .a
  </code></pre>