I am using Presto and have a column_A with complex JSON data where each cell has an array that looks like this:
[{"value":"aaa", "items":["246","123"],...}, {"value":"bbb", "items":["357","123"],...}]
What I am trying to do is extract from each cell only the JSON object where "items" has code "357".
So ideally the output of the query would be new data in Column_B that has one JSON object (not an array) and looks like this:
{"value":"bbb", "items":["357","123"],...}
Note: for each cell, there is only one object with the code "357", however, "item" may have more than 1 code inside its array. As in the examples above.
So far I tried the below, but it doesnt seem to be working:
SELECT JSON_EXTRACT(column_a, '$.(SELECT * from column_a where column_a::text LIKE '%357%')') AS column_extracted
FROM column_a
Does anyone have an idea of what I could try instead?