The solution is to use the hstore type. to use it, you must first create the corresponding extension.
The following is a simple example:
Iihero = # create extension hstore;
CREATE EXTENSION
Iihero = #
Iihero = # select 'a => 1, B => 2': hstore;
Hstore
--------------------
"A" => "1", "B" => "2"
(1 row)
Iihero = # insert into tjson values (1, 'a => 1, B => 2, c => 3': hstore );
INSERT 0 1
Iihero = # insert into tjson values (2, 'a => 2, B => 3, c => 4': hstore );
INSERT 0 1
Iihero = # select * from tjson where col2 @> 'a => 1 ';
Id | col2
---- + ------------------------------
1 | "a" => "1", "B" => "2", "c" => "3"
(1 row)
Iihero = # select * from tjson where col2 @> 'a => 1' and col2 @> 'B => 2 ';
Id | col2
---- + ------------------------------
1 | "a" => "1", "B" => "2", "c" => "3"
(1 row)
The difference is only the difference in syntax representation. You can also make full use of indexes.