I have a TEXT
column containing valid JSON string.
CREATE TABLE users(settings TEXT);
INSERT INTO users VALUES (\'{\"language\":\"en\",\"gender\":\
If you need an index on it, create an immutable function that takes the json as input and yields the field you want as output in a pl language, e.g.:
create function extract_language(text) returns text as $$
-- parse $1 as json
-- return $1.language
$$ language whatever immutable;
Then add an index on the expression:
create index users_language on users(extract_language(settings));
The index will then (potentially) get used in queries such as:
select * from users where extract_language(settings) = 'en';