16.7 JSON Function

This function returns p_string with all special characters escaped.

Syntax

APEX_ESCAPE.JSON (
    p_string  IN VARCHAR2 )
RETURN VARCHAR2;

Parameters

Table 16-7 JSON Function Parameters

Parameter Description

p_string

The string to be escaped.

Returns/Raised Errors

Table 16-8 JSON Function Returns

Return Description

VARCHAR2

The escaped string.

Example

The following example prints this: { "name": "O\u0027Brien"}

declare
    l_string varchar2(4000) := 'O''Brien';
begin
    sys.htp.p('{ "name": "'||apex_escape.json(l_string)||'"}');
end;