jsonb_strip_nulls with arrays? - Mailing list pgsql-hackers

From Florents Tselai
Subject jsonb_strip_nulls with arrays?
Date
Msg-id 4BCECCD5-4F40-4313-9E98-9E16BEB0B01D@gmail.com
Whole thread Raw
Responses Re: jsonb_strip_nulls with arrays?
List pgsql-hackers

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


pgsql-hackers by date:

Previous
From: Dagfinn Ilmari Mannsåker
Date:
Subject: [PATCH] Mention service key word more prominently in pg_service.conf docs
Next
From: Daniel Gustafsson
Date:
Subject: Re: [PATCH] Mention service key word more prominently in pg_service.conf docs