26.17 JSON Function

This function returns p_string with all special characters escaped.

Syntax

APEX_ESCAPE.JSON (
    p_string  IN VARCHAR2 )
RETURN VARCHAR2;

Parameters

Parameter Description
p_string The string to be escaped.

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;