Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: Vik Fearing <vik(at)postgresfriends(dot)org>, pgsql-hackers list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Date: 2020-02-15 03:24:58
Message-ID: CAKFQuwY2pywNG8S2bHEzFBeEzDkw=ziUbsw9KhS_cPc7FYPGGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, February 14, 2020, Bryn Llewellyn <bryn(at)yugabyte(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-02-15 04:55:08 Re: Parallel copy
Previous Message David G. Johnston 2020-02-15 03:19:40 Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.