Re: strip nulls functions for json and jsonb

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Thom Brown <thom(at)linux(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: strip nulls functions for json and jsonb
Date: 2014-10-26 20:18:03
Message-ID: 544D56FB.3020308@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 10/26/2014 04:14 PM, Thom Brown wrote:
> On 26 October 2014 20:07, Andrew Dunstan <andrew(at)dunslane(dot)net
> <mailto:andrew(at)dunslane(dot)net>> wrote:
>
>
> On 10/26/2014 03:50 PM, Pavel Stehule wrote:
>
> Hi
>
> I have a question,
>
> what is expected result of null strip of
>
> {"a": {"b": null, "c", null"} }
>
> ?
>
>
>
> Please remember not to top-post.
>
> The above is not legal json, so the answer would be an error.
>
>
> I believe Pavel means:
>
> {"a": {"b": null, "c": null} }

This is the expected result:

andrew=# select json_strip_nulls('{"a": {"b": null, "c": null} }');
json_strip_nulls
------------------
{"a":{}}
(1 row)

It is NOT expected that we replace an empty object with NULL (and then
strip it if it's a field value of an outer level object).

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-10-26 20:19:59 Re: TAP test breakage on MacOS X
Previous Message Tom Lane 2014-10-26 20:15:07 Re: Performance regression: 9.2+ vs. ScalarArrayOpExpr vs. ORDER BY