【发布时间】:2020-10-02 10:24:16
【问题描述】:
在 postgres 表中,我有一些这种格式的 jsonb
[{"type": "pet", "animal": "cat"}, {"type": "farm", "animal": "cow","colour": "brown"}]
但是我想把它变成这种格式
{"cat": {"type": "pet", "animal": "cat"}, "cow" {"type": "farm", "animal": "cow", "colour": "brown"}
而且我无法弄清楚或在互联网上找到任何拥有这种格式的 jsonb 的人。谁能解决这个问题?理想情况下,没有“颜色”键/值的数据集不会有 {“color”:null},但根本没有“颜色”键
我在 postgres 9.6
【问题讨论】:
标签: arrays json postgresql select unnest