On Thu, Jul 4, 2019 at 2:09 PM David G. Johnston <david.g.johns...@gmail.com>
wrote:

> On Thursday, July 4, 2019, Gianni Ceccarelli <dak...@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.

Reply via email to