I\'m trying the following query:
SELECT (json_data->\'position\'->\'lat\') + 1.0 AS lat FROM updates LIMIT 5;
(The +1.0 is just there
Adding a clarification because this comes up as the top hit for a 'JSONB float conversion' search - note that you need to wrap the JSON conversion in brackets, and then apply the '::' casting.
As mentioned above, the correct method is:
(json_data #>> '{field}')::float
If instead you try this it will fail:
json_data #>> '{field}'::float
This was the mistake I was making in my code and it took me a while to see it - easy fix once I noticed.