33.21 GET_VALUE_KIND Function

This function returns the kind of the value at a path position.

Syntax

APEX_JSON.GET_VALUE_KIND (
    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 t_kind;

Parameters

Table 33-27 GET_VALUE_KIND Parameters

Parameter Description
p_values Parsed JSON members. Defaults to g_values.
p_path Index into p_values.
p[0-4] Each %N in p_path is replaced by pN and every i-th %s or %d is replaced by the p[i-1].

Table 33-28 Returns

Return Description
t_kind The t_kind of the value at the given path position. Returns NULL if no data is found.

Example

The following example demonstrates

DECLARE
    j apex_json.t_values;
    k apex_json.t_kind;

    PROCEDURE print_kind( p_kind in apex_json.t_kind ) IS
    BEGIN
        dbms_output.put_line( 
            CASE p_kind
                WHEN apex_json.c_null      THEN 'NULL'
                WHEN apex_json.c_true      THEN 'true'
                WHEN apex_json.c_false     THEN 'false'
                WHEN apex_json.c_number    THEN 'NUMBER'
                WHEN apex_json.c_varchar2  THEN 'VARCHAR2'
                WHEN apex_json.c_object    THEN 'OBJECT'
                WHEN apex_json.c_array     THEN 'ARRAY'
                WHEN apex_json.c_clob      THEN 'CLOB' end );
    END print_kind;
BEGIN
    apex_json.parse(j, '{ "foo": 3, "bar": [1, 2, 3, 4] }');
    k := apex_json.get_value_kind (
             p_values => j,
             p_path   => 'bar[%d]',
             p0       => 2); -- returns the t_value for bar[2]
    print_kind(k);      -- 'NUMBER'
    k := apex_json.get_value_kind (
             p_values => j,
             p_path   => 'bar');
    print_kind(k);      -- 'ARRAY'
END;