Casting string column to JSONB

I’m running a postgresql DB.
I have a table users with column address which is currently a string datatype.
This column is already being used in some part of my codebase but I would like to change this column to a JSONB type so that it can be used to store values like {“city”:“value”, “country”: “value”}.
What’s the ideal query for this? Or do I have to create a computed value for this column to make this work?
The query I have in mind is ALTER TABLE users ALTER COLUMN address SET JSONB; but I’m not sure if this works so as not to break anything in the staging db.

I’d appreciate any help here please.

We have experimental support for column type changes like this. Here is an example:

demo@> create table a (a text);

Time: 2ms total (execution 2ms / network 0ms)

demo@> insert into a values ('{"foo": "bar"}');

Time: 2ms total (execution 2ms / network 0ms)

demo@> alter table a alter column a set data type jsonb;
ERROR: ALTER COLUMN TYPE from string to jsonb is only supported experimentally
HINT: See:
you can enable alter column type general support by running `SET enable_experimental_alter_column_type_general = true`
demo@> SET enable_experimental_alter_column_type_general = true;

Time: 0ms total (execution 0ms / network 0ms)

demo@> alter table a alter column a set data type jsonb;
NOTICE: ALTER COLUMN TYPE changes are finalized asynchronously; further schema changes on this table may be restricted until the job completes; some writes to the altered column may be rejected until the schema change is finalized

Time: 45ms total (execution 6ms / network 39ms)

demo@> select * from a;
  {"foo": "bar"}
(1 row)

Time: 1ms total (execution 0ms / network 0ms)

demo@> show create a;
  table_name |                      create_statement
  a          | CREATE TABLE public.a (
             |     a JSONB NULL,
             |     rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
             |     CONSTRAINT "primary" PRIMARY KEY (rowid ASC),
             |     FAMILY "primary" (a, rowid)
             | )
(1 row)

Time: 5ms total (execution 5ms / network 0ms)