Convert a Json-in-TEXT column to a real JSONB column

Viewed 25

I have a TEXT column that actually contains a stringized JSON. Now I just want to convert it to a real JSONB. How to do this from psql console?

1 Answers

If all data is valid JSON, then this should work:

demo:db<>fiddle

ALTER TABLE mytable ALTER COLUMN mytext_col TYPE jsonb USING mytext_col::jsonb;
Related