BigQuery 提取重复 JSON

BigQuery extract repeated JSON

我在 BigQuery 的一列中有以下数据:

{"id": "81", "type": ["{'id2': '12', 'type2': 'main'}", "{'id2': '15', 'type2': 'sub'}"]}

我想对此进行解析,并将 'id2' 和 'type2' 作为嵌套字段。我尝试使用 JSON_VALUE_ARRAY(data, "$.type") 正确创建嵌套行但无法处理提取 'id2' 和 'type2'。我相信也许 "s 是列表中的问题,我怎么能通过这些?

更新:

这是我想要实现的格式。

考虑以下方法

select 
  json_value(json, '$.id') id, array(
    select as struct json_value(trim(type, '"'), '$.id2') as id2, json_value(trim(type, '"'), '$.type2') as type2
    from unnest(json_extract_array(json, '$.type')) type
  ) type
from your_table