Schinckel.net Projects Tags About Contact Querying JSON in Postgres 2014 - 05 - 25 @ 16:25:15 postgres json sql here . Yesterday, I discovered how you can enable jsonb in postgres/psycopg2 . Today, I experimented around with how to query the data in json columns. There is documentation , but it wasn’t initially clear to me how the different operations worked. CREATE TABLE json_test ( id serial primary key , data jsonb ); INSERT INTO json_test ( data ) VALUES ( '{}' ), ( '{"a": 1}' ), ( '{"a": 2, "b": ["c", "d"]}' ), ( '{"a": 1, "b": {"c": "d", "e": true}}' ), ( '{"b": 2}' ); So far, so good. Let’s see what’s in there, to check: SELECT * FROM json_test ; id | data ----+-------------------------------------- 1 | {} 2 | {"a": 1} 3 | {"a": 2, "b": ["c", "d"]} 4 | {"a": 1, "b": {...