Function jsonb_build_object

Source
fn jsonb_build_object(args: impl Row, ctx: &Context) -> Result<JsonbVal>
Expand description

Builds a JSON object out of a variadic argument list. By convention, the argument list consists of alternating keys and values. Key arguments are coerced to text; value arguments are converted as per to_jsonb.

ยงExamples

query T
select jsonb_build_object('foo', 1, 2, 'bar');
----
{"2": "bar", "foo": 1}

query T
select jsonb_build_object(variadic array['foo', '1', '2', 'bar']);
----
{"2": "bar", "foo": "1"}