29.10 GET_BOOLEAN Function

This function returns a boolean number value.

Syntax

APEX_JSON.GET_BOOLEAN (
    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_default          IN BOOLEAN  DEFAULT NULL,
    p_values           IN t_values DEFAULT g_values )
RETURN BOOLEAN;

Parameters

Table 29-5 GET_BOOLEAN Function 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 %s or %d is replaced by the p[i-1].

p_default

The default value if the member does not exist.

p_values

Parsed JSON members. The default is g_values.

Returns

Table 29-6 GET_BOOLEAN Function Returns

Return Description

TRUE

Value at the given path position.

FALSE

Value at the given path position.

NULL

Value at the given path position.

VALUE_ERROR

Raises this error if p_values(p_path) is not boolean.

Example

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

DECLARE 
    j apex_json.t_values; 
BEGIN 
    apex_json.parse(j, '{ "items": [ 1, 2, { "foo": true } ] }'); 
    if apex_json.get_boolean(p_path=>'items[%d].foo', p0=>3,p_values=>j) then 
        dbms_output.put_line('items[3].foo is true'); 
END IF; 
END;