简体   繁体   中英

How to get an array from json?

How would I do the following in BigQuery:

SELECT CAST(JSON '[1, 2]' AS ARRAY<INTEGER>)

Invalid cast from JSON to ARRAY at [1:13]

JSON is so much more difficult to work with than the normal types in BQ!

I hope it can help:

SELECT JSON_EXTRACT_ARRAY ('[1, 2]') AS your_array

In this case, the result is an array as expected

Can you try this?

SELECT JSON_VALUE_ARRAY('[1,2]') AS sample_array;

As mentioned in this documentation this json function extracts the json value. For more json functions you can access the link provided above.

Output :

在此处输入图像描述

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM