PostgreSql : flatten json array data
Got it !

SELECT 
case jsonb_typeof(json)
    when 'string' then json-&gt;&gt;0
    when 'array' then jsonb_array_elements_text(json)
end
FROM jsonb_array_elements('{"test": ["a1", ["b1", "b2"]]}'::jsonb-&gt;'test') as json;