Re: jsonb_object() seems to be buggy. jsonb_build_object() is good. - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Date
Msg-id CAKFQuwY2pywNG8S2bHEzFBeEzDkw=ziUbsw9KhS_cPc7FYPGGQ@mail.gmail.com
Whole thread Raw
In response to Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.  (Bryn Llewellyn <bryn@yugabyte.com>)
Responses Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
List pgsql-hackers
On Friday, February 14, 2020, Bryn Llewellyn <bryn@yugabyte.com> wrote:

select jsonb_pretty(jsonb_object(
 '{a, 17, b, "dog", c, true}'::varchar[]
 ))

In other words, do the double quotes around "dog" have no effect? That would be a bad thing—and it would limit the usefulness of the jsonb_object() function.

The double quotes serve a specific purpose, to allow values containing commas to be treated as a single value (see syntax details for the exact rules) in the resulting array of text values.  The fact you don’t have to quote the other strings is a convenience behavior of the feature.

David J.

pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Next
From: Amit Kapila
Date:
Subject: Re: Parallel copy