Postgres: How to convert a json string to text?

后端 未结 5 1298
遥遥无期
遥遥无期 2020-11-30 05:35

Json value may consist of a string value. eg.:

postgres=# SELECT to_json(\'Some \"text\"\'::TEXT);
     to_json
-----------------
 \"Some \\\"text\\\"\"
         


        
5条回答
  •  囚心锁ツ
    2020-11-30 05:48

    In 9.4.4 using the #>> operator works for me:

    select to_json('test'::text) #>> '{}';
    

    To use with a table column:

    select jsoncol #>> '{}' from mytable;
    

提交回复
热议问题