数据仓库服务 GAUSSDB(DWS)-JSON/JSONB函数:json_to_recordset(array-json)

时间:2024-11-28 17:39:01

json_to_recordset(array-json)

描述:参考函数json_to_record,对数组内个每个元素,执行上述函数的操作,因此这要求数组内的每个元素都得是object-json。

返回类型:setof record

示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT * FROM json_to_recordset('[{"a":1,"b":{"d":"foo"},"c":true},{"a":2,"c":false,"b":{"d":"bar"}}]') AS x(a INT, b json, c BOOLEAN);
 a |      b      | c
---+-------------+---
 1 | {"d":"foo"} | t
 2 | {"d":"bar"} | f
(2 rows)

SELECT * FROM json_to_recordset('[{"a":1,"b":"foo","d":false},{"a":2,"b":"bar","c":true}]') AS x(a INT, b text, c BOOLEAN);
 a |  b  | c
---+-----+---
 1 | foo |
 2 | bar | t
(2 rows)
support.huaweicloud.com/sqlreference-830-dws/dws_06_0356.html