37.37 WRITE Procedure Signature 1
This procedure writes an array attribute of type VARCHAR2
.
Syntax
APEX_JSON.WRITE (
p_value IN VARCHAR2 );
Parameters
Parameter | Description |
---|---|
p_value |
The value to be written. |
Example
This example writes an array containing 1, "two", "long text", false, the current date and a JSON representation of an XML document.
DECLARE
l_clob clob := 'long text';
l_xml sys.xmltype := sys.xmltype('<obj><foo>1</foo><bar>2</bar></obj>');
BEGIN
-- if not executed within an APEX session context, JSON output needs to be initialized first
apex_json.initialize_clob_output;
apex_json.open_object;
apex_json.open_array; -- [
apex_json.write(1); -- 1
apex_json.write('two'); -- , "two"
apex_json.write(l_clob); -- , "long text"
apex_json.write(false); -- , false
apex_json.write(sysdate); -- , "2014-05-05T05:36:08Z"
apex_json.write(localtimestamp); -- , "2014-05-05T05:36:08.5434Z"
apex_json.write(current_timestamp); -- , "2014-05-05T05:36:08.5434+02:00"
apex_json.write(l_xml); -- , { "foo": 1, "bar": 2 }
apex_json.close_array; -- ]
apex_json.close_object;
dbms_output.put_line(apex_json.get_clob_output);
apex_json.free_output;
END;
Parent topic: APEX_JSON