You can find the AB = false rows with a JSON Path query:
select *
from test
where data @@ '$[*].A.AB == false'
If you don't know where exactly the key AB
is located, you can use:
select *
from test
where data @@ '$[*].**.AB == false'
To display all elements from the array as rows, you can use:
select id, e.*
from test
cross join jsonb_array_elements(jsonb_path_query_first(data, '$[*].B.BA.BAAA')) with ordinality as e(item, idx)
I include a column "id" as a placeholder for the primary key column, so that the source of the array element can be determined in the output.
Online example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…