remove null values from json

Поиск
Список
Период
Сортировка
От Michael Moore
Тема remove null values from json
Дата
Msg-id CACpWLjMXYaOJ+qDGX4xAduhWTHt0F62K2e2sDazH7tG_m9Qnpg@mail.gmail.com
обсуждение исходный текст
Ответы Re: remove null values from json
Список pgsql-sql
This is ALMOST what I want:
select json_strip_nulls ('[{ "f1":1 , "f2":null  , "f3":"NULL" , "f4":""  }]');
the result is:
"[{"f1":1,"f3":"NULL","f4":""}]"

As you can see, the "f2" object has been removed. I would also like to remove the f3 and f4 objects. 

I realize I won't be able to use the json_strip_nulls function to do this. I could brute force it by doing "json to array" then looping through the array and picking only the objects I want, and then using the chosen objects to build an new JSON document. 

I suspect there is a more elegant way to accomplish the same objective.
Ideas?

PS. It would be great to have a json_strip_values (json, array) where array contains the list of values you want removed. 

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

Предыдущее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: BYTEA
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: remove null values from json