title: Search Postgres JSON type using greater than/less than
body: <p>I am storing hashes in a JSON data type using rails 4 for an api and need to search for values in the hash that meet <code>&lt;</code> &amp; <code>&gt;</code> conditions.</p>
  
  <p>Using a hash like {location: {"lat": -112, "lng": 33}} for example, I need to be able to find a range of lat and longs.</p>
  
  <p>Something like:</p>
  
  <pre><code>Place.where("location -&gt;&gt; "lng" &lt; -111 &amp;&amp; &gt; -113)
  </code></pre>
  
  <p>It doesn't appear that Postgres 9.3 supports that though, is there a way in rails around this without using something like:</p>
  
  <pre><code>Place.all.select { |place| place.location["lng"] &lt; -111 &amp;&amp; &gt; -113 }
  </code></pre>