title: Modify arrays within objects in jq
body: <p>I have an array of objects, and want to filter the arrays in the <code>b</code> property to only have elements matching the <code>a</code> property of the object.</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;a&quot;: 3,
      &quot;b&quot;: [
        1,
        2,
        3
      ]
    },
    {
      &quot;a&quot;: 5,
      &quot;b&quot;: [
        3,
        5,
        4,
        3,
        5
      ]
    }
  ]
  </code></pre>
  <p>produces</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;a&quot;: 3,
      &quot;b&quot;: [
        3
      ]
    },
    {
      &quot;a&quot;: 5,
      &quot;b&quot;: [
        5,
        5
      ]
    }
  ]
  </code></pre>
  <p>Currently, I've arrived at</p>
  <pre><code>[.[] | (.a as $a | .b |= [.[] | select(. == $a)])]
  </code></pre>
  <p>That works, but I'm wondering if there's a better (shorter, more readable) way.</p>