collation, which is case-sensitive; if utf8mb4  is specified as the character set for the result, the server uses the default collation for this character set, which is not case-sensitive. 

When the data at the specified path consists of or resolves to a JSON null literal, the function returns SQL NULL . 

on_empty , if specified, determines how JSON_VALUE()  behaves when no data is found at the path given; this clause takes one of the following values: 

• NULL ON EMPTY : The function returns NULL ; this is the default ON EMPTY  behavior. 

• DEFAULT value  ON EMPTY : the provided value  is returned. The value’s type must match that of the return type. 

• ERROR ON EMPTY : The function throws an error. 

If used, on_error  takes one of the following values with the corresponding outcome when an error occurs, as listed here: 

• NULL ON ERROR : JSON_VALUE()  returns NULL ; this is the default behavior if no ON ERROR  clause is used. 

• DEFAULT value  ON ERROR : This is the value returned; its value must match that of the return type. 

• ERROR ON ERROR : An error is thrown. 

ON EMPTY , if used, must precede any ON ERROR  clause. Specifying them in the wrong order results in a syntax error. 

Error handling.  In general, errors are handled by JSON_VALUE()  as follows: 

•All JSON input (document and path) is checked for validity. If any of it is not valid, an SQL error is thrown without triggering the ON ERROR  clause. 

• ON ERROR  is triggered whenever any of the following events occur: 

•Attempting to extract an object or an array, such as that resulting from a path that resolves to multiple locations within the JSON document 

•Conversion errors, such as attempting to convert ’asdf’  to an UNSIGNED  value 

•Truncation of values 

•A conversion error always triggers a warning even if NULL ON ERROR  or DEFAULT ... ON ERROR is specified. 

•The ON EMPTY  clause is triggered when the source JSON document ( expr ) contains no data at the specified location ( path ). 

JSON_VALUE()  was introduced in MySQL 8.0.21. 

Examples.  Two simple examples are shown here: 

mysql> SELECT JSON_VALUE(’{"fname": "Joe", "lname": "Palmer"}’, ’$.fname’); +--------------------------------------------------------------+ | JSON_VALUE(’{"fname": "Joe", "lname": "Palmer"}’, ’$.fname’) | +--------------------------------------------------------------+ | Joe | 

