title: Filter hash with JsonPath
body: <p>I need to find a certain hash element where one of the keys is equal to a certain value. I've tried many ways and can't seem to figure it out with <code>jsonpath</code> gem.</p>
  
  <p>Need to get <code>tire</code> tag where <code>grip == 'bad'</code></p>
  
  <pre><code>require "jsonpath"
  
  hash = {
      :id =&gt; 1,
      :cars =&gt; [
          {:id =&gt; 1, :tire =&gt; {:grip =&gt; "good", :color =&gt; "black"}},
          {:id =&gt; 2, :tire =&gt; {:grip =&gt; "bad", :color =&gt; "red"}},
          {:id =&gt; 3, :tire =&gt; {:grip =&gt; "good", :color =&gt; "green"}}
      ]
  }
  
  puts JsonPath.on(hash, "$..tire[?(@['grip'] == 'bad')]").inspect
  </code></pre>
  
  <p>No results.</p>