public inbox for [email protected]  
help / color / mirror / Atom feed
From: Florents Tselai <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: jsonb_strip_nulls with arrays?
Date: Tue, 17 Sep 2024 12:26:36 +0300
Message-ID: <[email protected]> (raw)

Currently: 

jsonb_strip_nulls ( jsonb ) → jsonb
Deletes all object fields that have null values from the given JSON value, recursively. Null values that are not object fields are untouched.

> Null values that are not object fields are untouched. 

Can we revisit this and make it work with arrays, too?
Tbh, at first sight that looked like the expected behavior for me.
That is strip nulls from arrays as well.

This has been available since 9.5 and iiuc predates lots of the jsonb array work.

In practice, though, whenever jsonb_build_array is used (especially with jsonpath),
a few nulls do appear in the resulting array most of the times,
Currently, there’s no expressive way to remove this.  

We could also have jsonb_array_strip_nulls(jsonb) as well



view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: jsonb_strip_nulls with arrays?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox