fn jsonb_object_1d(array: ListRef<'_>) -> Result<JsonbVal>
Expand description
Builds a JSON object out of a text array.
The array must have either exactly one dimension with an even number of members, in which case they are taken as alternating key/value pairs, or two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair. All values are converted to JSON strings.
ยงExamples
query T
select jsonb_object('{a, 1, b, def, c, 3.5}' :: text[]);
----
{"a": "1", "b": "def", "c": "3.5"}
query error array must have even number of elements
select jsonb_object('{a, 1, b, "def", c}' :: text[]);
query error null value not allowed for object key
select jsonb_object(array[null, 'b']);
query T
select jsonb_object(array['a', null]);
----
{"a": null}