i was scraping large and complex data and have problem in a column that has array of nested json. to simulate the issue: -
CREATE TABLE public.test
(
id integer NOT NULL DEFAULT nextval('test_id_seq'::regclass),
testval jsonb
)
sample data
INSERT INTO test (id, test)
VALUES
(111,
'[{"type": {"value": 0, "displayName": "test0"}, "value": "outertestvalue0"}, {"type": {"value": 1, "displayName": "test1"}, "value": "outertestvalue1"}]'
);
INSERT INTO test (id, test)
VALUES
(222,
'[{"type": {"value": 2, "displayName": "test2"}, "value": "outertestvalue2"}, {"type": {"value": 3, "displayName": "test3"}, "value": "outertestvalue3"}]'
);
question is how to filter out base on specific conditions
select * from test where testval->'type' ->>'displayName'='test1';
this didnt work. can anyone point me to right direction?