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@127.0.0.1:26257/defaultdb> create table a (a text);
CREATE TABLE

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

demo@127.0.0.1:26257/defaultdb> insert into a values ('{"foo": "bar"}');
INSERT 1

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

demo@127.0.0.1:26257/defaultdb> alter table a alter column a set data type jsonb;
ERROR: ALTER COLUMN TYPE from string to jsonb is only supported experimentally
SQLSTATE: 0A000
HINT: See: https://go.crdb.dev/issue-v/49329/v21.1
--
you can enable alter column type general support by running `SET enable_experimental_alter_column_type_general = true`
demo@127.0.0.1:26257/defaultdb> SET enable_experimental_alter_column_type_general = true;
SET

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

demo@127.0.0.1:26257/defaultdb> 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
ALTER TABLE

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

demo@127.0.0.1:26257/defaultdb> select * from a;
        a
------------------
  {"foo": "bar"}
(1 row)

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

demo@127.0.0.1:26257/defaultdb> 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)