Postgres: How to convert a json string to text?

后端 未结 5 1280
遥遥无期
遥遥无期 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:43

    An easy way of doing this:

    SELECT  ('[' || to_json('Some "text"'::TEXT) || ']')::json ->> 0;
    

    Just convert the json string into a json list

提交回复
热议问题