45.46 PRINT_JSON_HTTP_HEADER Procedure
This procedure outputs a standard HTTP header for a JSON output.
Syntax
APEX_PLUGIN_UTIL.PRINT_JSON_HTTP_HEADER;
Parameters
None.
Example
This example shows how to use this procedure in the Ajax callback function of a plugin. This code outputs a JSON structure in the following format:
[{"d":"Display 1","r":"Return 1"},{"d":"Display 2","r":"Return 2"}]
-- Write header for the JSON stream.
apex_plugin_util.print_json_http_header;
-- initialize the JSON structure
sys.htp.p('[');
-- loop through the value array
for i in 1 .. l_values.count
loop
-- add array entry
sys.htp.p (
case when i > 1 then ',' end||
'{'||
apex_javascript.add_attribute('d', sys.htf.escape_sc(l_values(i).display_value), false, true)||
apex_javascript.add_attribute('r', sys.htf.escape_sc(l_values(i).return_value), false, false)||
'}' );
end loop;
-- close the JSON structure
sys.htp.p(']');
Parent topic: APEX_PLUGIN_UTIL