Brug json_each()
, f.eks.:
with my_table(items) as (
values (
'{"Apple":{"category":"fruit","price":100},"Orange":{"category":"fruit","price":80}}'::json
)
)
select key, (value->>'price')::numeric as price
from my_table,
json_each(items)
key | price
--------+-------
Apple | 100
Orange | 80
(2 rows)