I have a column x with data type jsonb
and the value looks like:
[
[{"string":"whateverstring1"}],
[{"string":"whateverstring2"}]
]
How to return each element of the array?
Something like this: "whateverstring1","whateverstring2"
demo:db<>fiddle
SELECT jsonb_array_elements(jsonb) -> 0 -> 'string'
FROM (
SELECT '[[{"string":"whateverstring1"}],[{"string":"whateverstring2"}]]'::jsonb
) s
jsonb_array_elements
extract each element into one row-> 0
gives the first element of the nested arrays which is {"string":"whateverstring1"}
-> 'string'
gives the value of the elementsIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With