I have a string field on BigQuery which looks like this:
[{"value": "yes", "source": "CURATED", "curated": true}, {"value": "yes", "source": "listing_service", "curated": false}]
How can I query this field if I only like to know the value parameter which in this case is yes
?
Meanwhile I found the solution for this with the function JSON_EXTRACT_SCALAR
The exact example could be queried like this.
JSON_EXTRACT_SCALAR(field_name,"$[0].value")
To complement your answer, JSON_Extract_SCALAR
is a good way to extract data but its consider legacy as show on JSON functions documentation page. I would suggest to use JSON_VALUE
instead.
select JSON_VALUE('[{"name":"juliana","country":"peru"}]',"$[0].name") as name
output
name
-------
juliana
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.