Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgres: how to select a json column as text

Tags:

postgresql

I have a json column, I want to select it as text, like :

select json_to_string(my_json_col) from my_table

How is that done ?

like image 918
Max L. Avatar asked Mar 01 '14 01:03

Max L.


1 Answers

I would try:

SELECT CAST(my_json_col AS VARCHAR) FROM my_table

or

SELECT my_json_cal::varchar FROM my_table

(I haven't worked with JSON in PostgreSQL yet, but the above is how PostgreSQL handles type conversions)

like image 119
dsh Avatar answered Oct 16 '22 00:10

dsh