I finally refused to search for a simple JSON path to extract them.
Instead, I wrote a redundant dirty query like the one below to do the task.
SELECT ... FROM ( SELECT SLICE(ARRAY[ JSON_EXTRACT(json_column, '$[0].id'), JSON_EXTRACT(json_column, '$[1].id'), JSON_EXTRACT(json_column, '$[2].id'), ... ], JSON_ARRAY_LENGTH(json_column)) ids FROM the.table ) t1 CROSS JOIN UNNEST(ids) AS t2(id) WHERE ...
I still want to know the best practice if you know another good CROSS JOIN way!
source share