I have a json string in bigquery that looks like that:
{"1":"eggs","2":"nuts","3":"fish"}
How could I extract all values without listing the keys? What I need is:
['eggs', 'nuts', 'fish']
I've tried [json_extract(json_string, '$[1]'), json_extract(json_string, '$[2]')]
and it does the job but it won't work if the number of keys increases
I managed to do this using this query:
CREATE TEMP FUNCTION jsonObjectValues(input STRING)
RETURNS Array<String>
LANGUAGE js AS """
RETURN Object.values(JSON.parse(input));
""";
SELECT
jsonObjectValues(value) AS values
FROM my_dataset
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.