I've found a potential bug. Why the "->" operator returns JSON instead of TEXT? It doesn't make sens for me, and the documentation doesn't inform about that.
postgres=# SELECT ('{"id": 1}'::json -> 'id')::int; ERROR: cannot cast type json to integer LINE 1: SELECT ('{"id": 1}'::json -> 'id')::int; postgres=# SELECT ('{"id": 1}'::json -> 'id')::text::int; int4 ------ 1 (1 row) postgres=# SELECT version(); version --------------------------------------------------------------------------------------------------------------- PostgreSQL 9.3beta1 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3, 64-bit (1 row)