title: How to convert PostgreSQL 9.4's jsonb type to float
body: <p>I'm trying the following query:</p>
  
  <pre><code>SELECT (json_data-&gt;'position'-&gt;'lat') + 1.0 AS lat FROM updates LIMIT 5;
  </code></pre>
  
  <p>(The +1.0 is just there to force conversion to float.  My actual queries are far more complex, this query is just a test case for the problem.)</p>
  
  <p>I get the error:</p>
  
  <pre><code>ERROR:  operator does not exist: jsonb + numeric
  </code></pre>
  
  <p>If I add in explicit casting:</p>
  
  <pre><code>SELECT (json_data-&gt;'position'-&gt;'lat')::float + 1.0 AS lat FROM updates LIMIT 5;
  </code></pre>
  
  <p>the error becomes:</p>
  
  <pre><code>ERROR:  operator does not exist: jsonb + double precesion
  </code></pre>
  
  <p>I understand that most jsonb values cannot be cast into floats, but in this case I know that the lats are all JSON numbers.</p>
  
  <p>Is there a function which casts jsonb values to floats (or return NULLs for the uncastable)?</p>