Re: Why does jsonb_set() remove non-mentioned keys? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Why does jsonb_set() remove non-mentioned keys?
Date
Msg-id CAKFQuwZWLNHw1=srVwe3c2X+5jjGOxv0rfaa9RuLk_Tu8zx8Hg@mail.gmail.com
Whole thread Raw
In response to Re: Why does jsonb_set() remove non-mentioned keys?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On Thu, Jul 4, 2019 at 2:09 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thursday, July 4, 2019, Gianni Ceccarelli <dakkar@thenautilus.net> wrote:

> select to_jsonb('null'::text);
┌──────────┐
│ to_jsonb │
├──────────┤
│ "null"   │
└──────────┘


Json null


Sorry, my bad on this last one.  You cannot use to_jsonb to construct a json null.  The only way, I think, to construct a json null scalar is with an explicit literal.

SELECT 'null'::jsonb;

The to_jsonb function always interprets a textual value passed to it as being the literal text and so the original query results in a json string whose content is "null"

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Converting to identity columns with domains on PK columns
Next
From: Laurenz Albe
Date:
Subject: Re: Converting to identity columns with domains on PK columns