json_strip_nulls()

Поиск
Список
Период
Сортировка
От Erwin Brandstetter
Тема json_strip_nulls()
Дата
Msg-id CAGHENJ5OckBWa22Cf=N9e68EZM2=_S8AWjWF-_xnGa+iktUh7g@mail.gmail.com
обсуждение исходный текст
Ответы Re: json_strip_nulls()  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-docs
The manual says this about json_strip_nulls()[1]:

> Deletes all object fields that have null values from the given JSON value, recursively. Null values that are not object fields are untouched.


But the function also strips all insignificant white space:

test=> SELECT json_strip_nulls(json '{"a": 1 ,
test'>                         "foo"  :  "bar"
test'>                         }');
  json_strip_nulls  
---------------------
 {"a":1,"foo":"bar"}

This is a useful feature to trim noise from json values, but unreliable while undocumented. So let's document the behavior:

Deletes all object fields that have null values from the given JSON value, recursively. Null values that are not object fields are untouched. json_strip_nulls additionally removes all insignificant white space.

If that's undesirable, let's remove the functionality - and provide a dedicated function for the task.
I found similar (unresolved) considerations here:

В списке pgsql-docs по дате отправления:

Предыдущее
От: PG Doc comments form
Дата:
Сообщение: array_to_string and string_to_array
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: json_strip_nulls()