strip values from json doc - Mailing list pgsql-sql

From Michael Moore
Subject strip values from json doc
Date
Msg-id CACpWLjNq53+P6T8ULc=UtOnarTm-xYh5-Pfuo0Ea_odt2pXw-A@mail.gmail.com
Whole thread Raw
List pgsql-sql
<div dir="ltr"><span style="font-size:12.8px">This is ALMOST what I want:</span><br style="font-size:12.8px" /><font
face="monospace,monospace" style="font-size:12.8px">select json_strip_nulls ('[{ "f1":1 , "f2":null  , "f3":"NULL" ,
"f4":"" }]');</font><br style="font-size:12.8px" /><div style="font-size:12.8px">the result is:</div><div
style="font-size:12.8px"><fontface="monospace, monospace">"[{"f1":1,"f3":"NULL","f4":""}]"</font><br /></div><div
style="font-size:12.8px"><br/></div><div style="font-size:12.8px">As you can see, the "f2" object has been removed. I
would <b>also</b> liketo remove the f3 and f4 objects. </div><div style="font-size:12.8px"><br /></div><div
style="font-size:12.8px">Irealize I won't be able to use the json_strip_nulls function to do this. I could brute force
itby doing "json to array" then looping through the array and picking only the objects I want, and then using the
chosenobjects to build an new JSON document. </div><div style="font-size:12.8px"><br /></div><div
style="font-size:12.8px">Isuspect there is a more elegant way to accomplish the same objective.</div><div
style="font-size:12.8px">Ideas?</div><divstyle="font-size:12.8px"><br /></div><div style="font-size:12.8px">PS. It
wouldbe great to have a <span style="font-family:monospace,monospace">json_strip_values (json, array) where array
containsthe list of values you want removed. </span></div></div> 

pgsql-sql by date:

Previous
From: John DeSoi
Date:
Subject: Re: BYTEA vs BLOB
Next
From: Eugene Yin
Date:
Subject: Re: BYTEA vs BLOB