title: How can I get jmespath filter to return true if the value exists and false if it doesn't (python)
body: <p>This is an extension from a previous question that is unresolved but another way of looking at the problem <a href="https://stackoverflow.com/questions/68163640/filter-json-using-jmespath-and-return-value-if-expression-exist-if-it-doesnt-r">HERE</a></p>
  <pre><code>{
    &quot;name&quot;: &quot;Sarah&quot;,
    &quot;region&quot;: &quot;south west&quot;,
    &quot;age&quot;: 21,
    &quot;occupation&quot;: &quot;teacher&quot;,
    &quot;height&quot;: 145,
    &quot;education&quot;: &quot;university&quot;,
    &quot;favouriteMovie&quot;: &quot;matrix&quot;,
    &quot;gender&quot;: &quot;female&quot;,
    &quot;country&quot;: &quot;US&quot;,
    &quot;level&quot;: &quot;medium&quot;,
    &quot;tags&quot;: [],
    &quot;data&quot;: &quot;abc&quot;,
    &quot;moreData&quot;: &quot;xyz&quot;,
    &quot;logging&quot; : {
      &quot;systemLogging&quot; : [ {
        &quot;environment&quot; : &quot;test&quot;,
        &quot;example&quot; : [ &quot;this&quot;, &quot;is&quot;, &quot;an&quot;, &quot;example&quot;, &quot;array&quot; ]
      } ]
    }
  }
  </code></pre>
  <p>If I wanted to see if a value exists for simple key value pairs in a python dictionary I could use the jmespath query to do so</p>
  <pre><code>&quot;occupation == `teacher`&quot;
  &gt;&gt; True
  &quot;occupation == `dancer`&quot;
  &gt;&gt; False
  </code></pre>
  <p>But with more complicated data e.g nested dictionaries with lists/arrays the best I can do is filter to obtain the value</p>
  <pre><code>&quot;logging.systemLogging[?environment == `test`] | [0].enabled&quot;
  &gt;&gt; test
  &quot;logging.systemLogging[?environment == `prod`] | [0].enabled&quot;
  &gt;&gt; None
  </code></pre>
  <p>How do I get the example above to return <code>True</code> or <code>False</code> rather then the value if it exists and <code>None</code> or empty array <code>[]</code> if it doesn't</p>