JSON Parsing Functions

JSON_VALUE ( <json_string>, <json_path> )

Retrieves a JSON value corresponding to the given json path. If the json path is not present then None is returned.

Note: Given JSON string should be valid

> SELECT 
JSON_VALUE('{"fruits": [{"apples": 5, "oranges": 10}, 
{"apples": 2, "oranges": 4}], 
"vegetables": [{"lettuce": 7, "kale": 8}]}','$.fruits') AS string_array
[{"apples":5,"oranges":10},{"apples":2,"oranges":4}]

> SELECT 
JSON_VALUE('{"fruits": [{"apples": 5, "oranges": 10}, 
{"apples": 2, "oranges": 4}], 
"vegetables": [{"lettuce": 7, "kale": 8}]}','$.fruits[1].oranges') 
AS string_array
10

Last updated