37.19 GET_T_VARCHAR2 Function
This function returns the varchar2 attributes of an array.
Syntax
APEX_JSON.GET_T_VARCHAR2 (
p_path IN VARCHAR2,
p0 IN VARCHAR2 DEFAULT NULL,
p1 IN VARCHAR2 DEFAULT NULL,
p2 IN VARCHAR2 DEFAULT NULL,
p3 IN VARCHAR2 DEFAULT NULL,
p4 IN VARCHAR2 DEFAULT NULL,
p_values IN t_values DEFAULT g_values )
RETURN apex_t_varchar2;
Parameters
Parameter | Description |
---|---|
p_path |
Index into p_values .
|
p[0-4] |
Each %N in p_path is replaced by pN and every i-th% or %d is replaced by the p[i-1] .
|
p_values |
Parsed JSON members. The default is g_values .
|
Returns
Array member values if the referenced t_value
is an array. An array with just the referenced value if its type can be converted to a varchar2.
Raises
Return | Description |
---|---|
VALUE_ERROR |
On conversion errors. |
Example
This example parses a JSON and prints the value at position 1.
declare
j apex_json.t_values;
l_elements apex_t_varchar2;
begin
apex_json.parse(j, '{ "foo": ["one", "two"], "bar": "three" }');
l_elements := apex_json.get_t_varchar2 (
p_values => j,
p_path => 'foo' );
for i in 1 .. l_elements.count loop
sys.dbms_output.put_line(i||':'||l_elements(i));
end loop;
l_elements := apex_json.get_t_varchar2 (
p_values => j,
p_path => 'bar' );
for i in 1 .. l_elements.count loop
sys.dbms_output.put_line(i||':'||l_elements(i));
end loop;
end;
Output:
1:one
2:two
1:three
Parent topic: APEX_JSON