21.22 INITIALIZE_OUTPUT Procedure

This procedure initializes the output interface. You only have to call this procedure if you want to modify the parameters below. Initially, output is already configured with the defaults mentioned in the parameter table.

Syntax

APEX_JSON.INITIALIZE_OUTPUT (
    p_http_header     in boolean     default true,
    p_http_cache      in boolean     default false,
    p_http_cache_etag in varchar2    default null, 
    p_indent          in pls_integer default null );

Parameters

Table 21-26 INITIALIZE_OUTPUT Procedure Parameters

Parameter Description

p_http_header

If TRUE (the default), write an application/JSON mime type header.

p_http_cache

This parameter is only relevant if p_write_header is TRUE. If TRUE, writes Cache-Control: max-age=315360000. If FALSE (the default), writes Cache-Control: no-cache. Otherwise, does not write Cache-Control.

http_cache_etag

If not null, writes an etag header. This parameter is only used if P_HTTP_CACHE is true.

p_indent

Indent level. Defaults to 2, if debug is turned on, otherwise defaults to 0.

Example

This example configures APEX_JSON to not emit default headers, because they are written directly.

BEGIN
  apex_json.initialize_output (
      p_http_header => false );
 
  sys.owa_util.mime_header('application/json', false);
  sys.owa_util.status_line(429, 'Too Many Requests');
  sys.owa_util.http_header_close;
  --
  apex_json.open_object;
  apex_json.write('maxRequestsPerSecond', 10);
  apex_json.close_object;
END;