37.7 FIND_PATHS_LIKE Function
This function returns paths into p_values
that match a given pattern.
Syntax
APEX_JSON.FIND_PATHS_LIKE (
p_return_path IN VARCHAR2,
p_subpath IN VARCHAR2 DEFAULT NULL,
p_value IN VARCHAR2 DEFAULT NULL,
p_values IN t_values DEFAULT g_values )
RETURN apex_t_varchar2;
Parameters
Parameter | Description |
---|---|
p_return_path |
Search pattern for the return path.. |
p_subpath |
(Optional) Search pattern under p_return_path .
|
p_value |
(Optional) Search pattern for value. |
p_values |
Parsed JSON members. Default is g_values .
|
Returns/Raised Errors
Return/Error | Description |
---|---|
apex_t_varchar2 |
Table of paths that match the pattern. |
VALUE_ERROR |
Raises this error if p_values(p_path is not an array or object.
|
Example
This example parses a JSON string, finds paths that match a pattern, and prints the values under the paths.
DECLARE
j apex_json.t_values;
l_paths apex_t_varchar2;
BEGIN
apex_json.parse(j, '{ "items": [ { "name": "Amulet of Yendor", "magical": true }, '||
{ "name": "Slippers", "magical": "rather not" } ]}');
l_paths := apex_json.find_paths_like (
p_values => j,
p_return_path => 'items[%]',
p_subpath => '.magical',
p_value => 'true' );
dbms_output.put_line('Magical items:');
FOR i in 1 .. l_paths.count LOOP
dbms_output.put_line(apex_json.get_varchar2(p_values => j, p_path => l_paths(i)||'.name'));
END LOOP;
END;
Parent topic: APEX_JSON