问题
I have a table with jsonb
field. Some of the rows are an array of objects, but some of the others are string.
I want to convert red rows to array of objects.
My table structure:
How I can do this in PostgreSQL
?
回答1:
Following SQL should do the trick:
update your_table_name
set content = (content#>>'{}')::jsonb
where jsonb_typeof(content)='string';
Reference: https://www.postgresql.org/docs/10/functions-json.html
来源:https://stackoverflow.com/questions/60824247/convert-json-string-to-jsonb