我有一个与此类似的 JSON 数组
[{"key":"Email","slug":"customer-email","value":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="debfbcbd9eb9b3bfb7b2f0bdb1b3" rel="noreferrer noopener nofollow">[email protected]</a>"},{"key":"Phone Number","slug":"mobile-phone-number","value":"123456789"},{"key":"First Name","slug":"first-name","value":"abc"},{"key":"Last Name","slug":"last-name","value":"xyz"},{"key":"Date of birth","slug":"date-of-birth","value":"01/01/1990"}]
但棘手的部分是,这个数组存储为字符串。所以我认为第一步是将字符串转换为数组,然后取消嵌套,然后按照 here 中的方法进行操作
我想知道这个方法是否可行,如果可以的话,我想我面临的挑战是将字符串转换为数组。如果没有,或者您有更有效的方法,请帮忙。谢谢
最佳答案
select json_extract_array(
"""[{"key":"Email","slug":"customer-email","value":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="54353637143339353d387a373b39" rel="noreferrer noopener nofollow">[email protected]</a>"},{"key":"Phone Number","slug":"mobile-phone-number","value":"123456789"},{"key":"First Name","slug":"first- name","value":"abc"},{"key":"Last Name","slug":"last-name","value":"xyz"},{"key":"Date of birth","slug":"date-of-birth","value":"01/01/1990"}]""");
关于json - 如何提取在 BigQuery 中存储为字符串的 JSON 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64167168/