I use cross join to unnest nested json values, but when filed not found it returns no record. is there a solution for the below using left join somehow?
create table json_example as
select '{"id": "21397", "fields": { "labels": [] , "subtasks": [{"id": "10217"}] }}'::jsonb as value
union all
select '{"id": "21397", "fields": { "labels": [] , "subtasks" : [] }}'::jsonb
returns both rows:
select * from json_example
the below returns only one row:
select subtasks.value->>'id'
from json_example h cross join
jsonb_array_elements(value->'fields'->'subtasks') as subtasks
how i can solve the above, problem to have both records?