I have an JSON objet withs ID / keys.
Within those keys is the result of each analysis of each ID.
"raw_result":{"3117092402546":true,"3110924118082":false,"3117014230082":true,"3171295576130":true}
I need to extract that information in some way that allows me to make queries later. For example: an array of data.
result I expected
**document_id id result**
918348 3117092402546 true
918348 3110924118082 false
918348 3117014230082 true
918348 3171295576130 true
could you help me?
Try this one:
WITH sample AS (
SELECT JSON_QUERY('{"raw_result":{"3117092402546":true,"3110924118082":false,"3117014230082":"true","3171295576130":true}}', '$.raw_result') json
)
SELECT k AS id, v AS result
FROM sample,
UNNEST(bqutil.fn.json_extract_keys(json)) k WITH OFFSET ki,
UNNEST(bqutil.fn.json_extract_values(json)) v WITH OFFSET vi
WHERE ki = vi
;
And for the UDFs I've used, you can check them on below site:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.