Reputation: 1938
I have a TEXT column in my table (it's actually 'character varying'), but the data in the column is valid json. How can I access fields in this column using Postgres 9.3's new JSON functions?
What I basically want is a way to be able to do:
SELECT mycolumn->'myfield' from mytable;
Do I need to convert the entire column to the native JSON datatype, or is there an easy/efficient way to cast the cells?
Upvotes: 4
Views: 2653
Reputation: 656714
You need a type cast:
SELECT mycolumn::json->'myfield' FROM mytable;
Upvotes: 9