PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Postgres:expanda a coluna JSON em linhas

select id,
    (details ->> 'json1')::int as json1,
    (details ->> 'json2')::int as json2
from (
    select id, json_array_elements(details) as details
    from things
) s
;
 id | json1 | json2 
----+-------+-------
  1 |   123 |   456
  1 |   124 |   457
  2 |   234 |   567