I have a TEXT
column containing valid JSON string.
CREATE TABLE users(settings TEXT);
INSERT INTO users VALUES ('{"language":"en","gender":"male"}');
INSERT INTO users VALUES ('{"language":"fr","gender":"female"}');
INSERT INTO users VALUES ('{"language":"es","gender":"female"}');
INSERT INTO users VALUES ('{"language":"en","gender":"male"}');
I want to transform some fields into a query-able format.
A REGEXP_REPLACE
for each field would do (language
field and gender
field). But since it's valid JSON, is there way to:
- Convert into JSON type
- Convert into hstore type
- Or any other feasible ways
SQLFiddle: http://sqlfiddle.com/#!12/54823