I'm getting a headache trying to figure out how to read a JSON with the following format in Athena
{
"id": "1",
"key1": {
"dynamic_key_here": [
{"id": "A", "key2": "content I want"}
]
}
}
Let's call this column "data", and the table it's from "info"
With a SELECT json_extract(data, '$.key1') FROM info I can get to the second layer and retrieve it as a json, but here I'm stuck because the key of this second layer is dynamic, I don't know it in advance.
All I need is the content of the string contained in key2 in that second layer, (it's a 1:1 relation with what's outside the json in the table, basically it's just like adding a column to my table, no unnesting needed) can anyone help?