Skip to content

JSON_EXISTS

JSON_EXISTS(json_document, json_path, json_exists_error_handling)

Section titled “JSON_EXISTS(json_document, json_path, json_exists_error_handling)”
  • json_document: This parameter is required. It is the JSON document in which the search will be processed. It should be in either a VARCHAR2, BLOB, or CLOB data type. In the case of a NULL value, the function returns FALSE.
  • json_path: This parameter is required. It is the JSON path expression which is used to search within the json_document. It should contain one or more JSON keys, through which it is possible to traverse the JSON document.
  • json_exists_error_handling: This parameter is optional. It specifies how the function behaves when an error occurs. Its possible values are ‘strict’ or ‘lax’. If it is set to ‘strict’, the function will raise an error when an invalid JSON document or JSON path is used. If it is set to ‘lax’, the function will return a FALSE when it encounters an erroneous section within the JSON document or JSON path. If this parameter is not specified, it defaults to ‘strict’.
SELECT JSON_EXISTS(
'{"employees":["John", "Anna", "Peter"]}' FORMAT JSON,
'$.employees[0]'
) AS "JSON_EXISTS_Test"
FROM dual;
JSON_EXISTS_Test
----------------
1

In the provided example, JSON_EXISTS function is being used to check if the JSON object contains “John” at first position in the “employees” array. As “John” is present at the first position in the “employees” array, the function returns 1, indicating true.