For Postgres 9.4+ see adamc’s later answer. Or:
Original answer for Postgres 9.3
Yes, that’s possible:
SELECT *
FROM tbl t, json_array_elements(t.json_col->'emails') AS elem
WHERE elem->>'id' = 123;
tbl
being your table name, json_col
the name of the JSON column.
See also:
About the implicit CROSS JOIN LATERAL
:
Index to support this kind of query: