37.18 GET_T_NUMBER Function

This function returns the numeric attributes of an array.

Syntax

APEX_JSON.GET_T_NUMBER (
    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_number;

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. Default p_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 number.

Return Description
VALUE_ERROR On conversion errors.

Example

This example parses a JSON string and prints the value at position 1.

    declare
         j          apex_json.t_values;
         l_elements apex_t_number;
     begin
         apex_json.parse(j, '{ "foo": [111, 222], "bar": 333 }');
         l_elements := apex_json.get_t_number (
                           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_number (
                           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:111
     2:222
     1:333