JSON_EXISTS_PATH
Description
Used to determine whether the field specified by <path> exists in JSON data. Returns TRUE if it exists, FALSE if it does not exist.
Syntax
JSON_EXISTS_PATH (<json_object>, <path>)
Parameters
<json_object>JSON type, determine whether the path specified by<path>exists in it.<path>String type, specifies the path.
Return Value
- BOOL type, returns TRUE if it exists, FALSE if it does not exist
- NULL: If either
<json_object>or<path>is NULL, returns NULL.
Examples
- Example 1
SELECT JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', '$.name');+------------------------------------------------------------+
| JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', '$.name') |
+------------------------------------------------------------+
| 1 |
+------------------------------------------------------------+ - Example 2
SELECT JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', '$.age');+-----------------------------------------------------------+
| JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', '$.age') |
+-----------------------------------------------------------+
| 0 |
+-----------------------------------------------------------+ - NULL parameters
SELECT JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', NULL);+--------------------------------------------------------+
| JSON_EXISTS_PATH('{"id": 123, "name": "doris"}', NULL) |
+--------------------------------------------------------+
| NULL |
+--------------------------------------------------------+SELECT JSON_EXISTS_PATH(NULL, '$.age');+---------------------------------+
| JSON_EXISTS_PATH(NULL, '$.age') |
+---------------------------------+
| NULL |
+---------------------------------+