json_strip_nulls()
От | Erwin Brandstetter |
---|---|
Тема | json_strip_nulls() |
Дата | |
Msg-id | CAGHENJ5OckBWa22Cf=N9e68EZM2=_S8AWjWF-_xnGa+iktUh7g@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: json_strip_nulls()
|
Список | pgsql-docs |
> 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"}
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:
There were related requests on Stackoverflow:
Regards
Erwin
В списке pgsql-docs по дате отправления: