Returns whether the input string is a valid JSON document.
Returns NULL if the input is NULL.
Syntax
JSON_IS_VALID(<json_string>)
Aliases
JSON_VALID(<json_string>)
Parameters
| Parameter | Description | Supported input types |
|---|
<json_string> | The string to validate as JSON. | TEXT |
Return Type
The JSON_IS_VALID function returns a result of type BOOL.
If you want to know why the input string is invalid JSON, you can also use the CHECK_JSON function.
Examples
Example
The following code example validates a valid JSON string and returns TRUE:
SELECT JSON_IS_VALID('{"name": "John"}');
| json_is_valid boolean |
|---|
| True |
Rows: 1Execution time: 5.85ms
Example
The following code example validates an invalid JSON string (two JSON objects concatenated) and returns FALSE:
SELECT JSON_IS_VALID('{"name": "John"}{"name": "John"}');
| json_is_valid boolean |
|---|
| False |
Rows: 1Execution time: 5.33ms