PostgreSQL 9.2 - Convert TEXT json string to type json/hstore

前端 未结 6 902
难免孤独
难免孤独 2021-01-31 07:15

I have a TEXT column containing valid JSON string.

CREATE TABLE users(settings TEXT);

INSERT INTO users VALUES (\'{\"language\":\"en\",\"gender\":\         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 07:59

    Adding to another comment, here is a one-liner in a query(without the need to update)

    regexp_replace(trim(both '"' from settings::text), '\\"', '"', 'g')::json as column_name;
    

提交回复
热议问题