37.35 TO_XMLTYPE Function

This procedure parses a JSON-formatted varchar2 or CLOB and converts it to an xmltype.

Syntax

APEX_JSON.TO_XMLTYPE (
    p_source   IN VARCHAR2,
    p_strict   IN BOOLEAN DEFAULT TRUE )
RETURN sys.xmltype;

APEX_JSON.TO_XMLTYPE (
    p_source   IN CLOB,
    p_strict   IN BOOLEAN DEFAULT TRUE )
RETURN sys.xmltype;

Parameters

Parameter Description
p_source The JSON source (VARCHAR2 or CLOB)
p_strict If TRUE (default), enforce strict JSON rules

Returns

Return Description
sys.xmltype An xmltype representation of the JSON data.

Example

This example parses JSON and prints the XML representation.

DECLARE
    l_xml xmltype;
BEGIN
    l_xml := apex_json.to_xmltype('{ "items": [ 1, 2, { "foo": true } ] }');
    dbms_output.put_line(l_xml.getstringval);
END;