26.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
Table 26-3 FIND_PATHS_LIKE Function Parameters
Parameter | Description |
---|---|
|
Search pattern for the return path.. |
|
Search pattern under |
|
Search pattern for value (optional). |
|
Parsed JSON members. The default is |
Returns/Raised Errors
Table 26-4 FIND_PATHS_LIKE Function Returns and Raised Errors
Return | Description |
---|---|
|
Table of paths that match the pattern. |
|
Raises this error if |
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