title: Extracting values with jq only when they exist
body: <p>I have a large file of records that contain fields that look something like this:</p>
  <pre><code>   {
    &quot;id&quot;: &quot;1000001&quot;,
    &quot;updatedDate&quot;: &quot;2018-12-21T01:52:00Z&quot;,
    &quot;createdDate&quot;: &quot;1993-11-30T02:59:25Z&quot;,
    &quot;varFields&quot;: [
      {
        &quot;fieldTag&quot;: &quot;b&quot;,
        &quot;content&quot;: &quot;1000679727&quot;
      },
      {
        &quot;fieldTag&quot;: &quot;v&quot;,
        &quot;content&quot;: &quot;v.1&quot;
      }
  </code></pre>
  <p>}</p>
  <p>I need to extract the .content element along with other things, but only when the fieldTag associated with it is &quot;v&quot;. Only some records contain a fieldTag &quot;v&quot;.</p>
  <p>When I try to parse using</p>
  <pre><code> (.varFields[] |select(.fieldTag==&quot;v&quot;) | &quot;\(.content)&quot;) // &quot;&quot;
  </code></pre>
  <p>it works fine so long as v is present. However, when it is not present, I get</p>
  <pre><code>jq: error (at &lt;stdin&gt;:353953): Cannot iterate over null (null)
  </code></pre>
  <p>I tried to get rid of the error with multiple variations, including things to the effect of</p>
  <pre><code>(select((.varFields[] |select(.fieldTag==&quot;v&quot;) | .content) != null) | .varFields[] |select(.fieldTag==&quot;v&quot;) | &quot;\(.content)&quot;) // &quot;&quot;
  </code></pre>
  <p>but I'm still getting the same error. What am I missing?</p>