pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTurn a json column into a table
2+ messages / 2 participants
[nested] [flat]
* Turn a json column into a table
@ 2022-02-15 06:23 Shaozhong SHI <shishaozhong@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Shaozhong SHI @ 2022-02-15 06:23 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
There is a JSON column in a table. It contains key value pairs, just like
a dictionary. What is the best way to turn this column into a data table?
Regards,
David
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Turn a json column into a table
@ 2022-02-15 06:27 Thomas Kellerer <shammat@gmx.net>
parent: Shaozhong SHI <shishaozhong@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Kellerer @ 2022-02-15 06:27 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Shaozhong SHI schrieb am 15.02.2022 um 07:23:
> There is a JSON column in a table. It contains key value pairs, just
> like a dictionary. What is the best way to turn this column into a
> data table?
jsonb_each() is one option:
select j.*
from the_table t
cross join jsonb_each(t.the_column) as j(key, value);
If the column uses the json type (rather than the recommended jsonb) you can
need to use json_each() instead.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-02-15 06:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 06:23 Turn a json column into a table Shaozhong SHI <shishaozhong@gmail.com>
2022-02-15 06:27 ` Thomas Kellerer <shammat@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox