I have rather abstract question on PostgreSQL jsonb data.
For example I have a table called… table_one, where I have a column:
my_jsonb_column jsonb;
In 100% cases in contains flat json structure like
example:
{"one": null, "two": 0, "three": "" }
might be different length or null but always flat.
My goal is like that.
Whenever I select this column I need to somehow convert empty string values “” into null for each member of json where it’s value is “”
example :
{"one": null, "two": 0, "three": "" } - > {"one": null, "two": 0, "three": null }
Preferable without PLPGsQL
Postgres version - 11
Thank you.
""and replace with null? -->WITH j (val) AS ( VALUES ('{"one": null, "two": 0, "three": "" }'::jsonb)) SELECT replace(val::text,'""','null')::jsonb FROM j