json_each_text() 是一个系统函数,它将顶层的 JSON 对象展开为一组键/值对,其中值以 text 类型返回。
json_each_text() 函数于 PostgreSQL 9.3 中添加。
用法
json_each_text (json) → setof record (keytext,valuetext)
要将值提取为 json 类型,请使用 json_each()。
变更历史
- PostgreSQL 9.3
- 添加 (提交 a570c98d)
示例
json_each_text() 的基本用法示例
postgres=# SELECT key, value
FROM json_each_text('{"a":"foo", "b":{"bar":"baz"}}');
key | value
-----+---------------
a | foo
b | {"bar":"baz"}
(2 rows)
参考资料
- PostgreSQL 文档: JSON 处理函数
