parse
Use the parse policy to control the parsing of an input document. When the input document is a JSON string, the string is parsed instead of copied over.
Gateway | Policy version |
---|---|
DataPower® API Gateway | 2.0.0 2.1.0 (DataPower API Gateway Version 10.0.3.0 or later) 2.2.0 (DataPower API Gateway Version 10.5.0.5 or later) |
This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see Parse.
About parse
- parse:
version: version
title: title
description: description
use-content-type: request_header_usage_setting
parse-settings-reference:
.
.
.
references_to_parse_settings
.
.
.
input: input_message
output: output_message
Properties
Property | Required | Description | Data type |
---|---|---|---|
version | Yes | The policy version number. | string |
title | No | The title of the policy. | string |
description | No | A description of the policy. | string |
use-content-type | No | If this setting is enabled and the parse setting is configured to detect the document type,
the parse operation uses the Content-Type specified in the request headers.If
this setting is enabled and the document type in the parse setting is configured for either JSON or
XML, the parse operation uses the Enabling this setting is applicable only when the expected
If this setting is not enabled, the parse operation uses either the document type specified in the parse setting, or the detected document type if the parse setting is configured to detect the document type. The default value is
|
boolean |
|
No | An existing valid object from which to retrieve default property values for the dynamic object. | string |
document_type | No | The type of document to parse. Specify one of the following values:
Query variables in a GET request can be sent as a JSON string in a query parameter called
|
string |
max_doc_size | No | Optionally, the maximum document size in bytes that the parse operation accepts. This setting
provides threat protection by enforcing the maximum document size. Enter a value in the range 0 -
5368709121. A document is rejected when its size exceeds the maximum size. A value of 0 indicates an
unlimited document size. When set to 0, the operation result does not return the document size. This
setting is applicable to JSON, XML, or GraphQL input documents. The default value is 4194304. |
integer |
max_nesting_depth | No | Optionally, the maximum nesting depth of an XML, JSON, or GraphQL message that the parse
operation accepts. This setting provides threat protection by enforcing limits in the message.
Enter a value in the range 0 - 4096. A document is rejected when its nesting depth exceeds the maximum depth. A value of 0 indicates unlimited nesting depth. When set to 0, the operation result does not return the nesting depth. The default value is 512. |
integer |
max_width | No | Optionally, the maximum width of the payload that the parse operation accepts.
Enter a value in the range 0 - 65535. The document is rejected when its width exceeds the maximum width. A value of 0 indicates unlimited width. When set to 0, the operation result does not return the width of the document. The default value is 4096. |
integer |
max_name_length | No | Optionally, the maximum name length in bytes in a document that the parse operation accepts.
The length includes any white space that is contained between tags in XML or quotation marks in JSON. Enter a value in the range 0 - 8192. A document is rejected when its name length exceeds the maximum length. A value of 0 indicates unlimited name length. When set to 0, the operation result does not return the name length of a document. The default value is 256. |
integer |
max_value_length | No | Optionally, the maximum value length in bytes in a document that the parse operation accepts.
The length includes any white space that is contained between tags in XML or quotation marks in JSON. Enter a value in the range 0 - 5368709121. A document is rejected when its value length exceeds the maximum length. A value of 0 indicates unlimited value length. When set to 0, the operation result does not return the value length of a document. The default value is 8192. |
integer |
max_unique_names | No | Optionally, the maximum number of unique names in a JSON or XML document that the parse
operation accepts.
Enter a value in the range 0 - 1048575. A document is rejected when the number of unique names in the document exceeds the maximum number. A value of 0 indicates an unlimited number of unique names. When set to 0, the operation result does not return the number of unique names in a document. The default value is 1024. |
integer |
max_unique_prefixes | No | Optionally, the maximum number of unique XML namespace prefixes in a document that the parse
operation accepts. This limit counts multiple prefixes defined for the same namespace, but does not
count multiple namespaces defined in different parts of the input document under a single prefix.
Enter a value in the range 0 - 262143. A document is rejected when the number of unique prefixes in
the document exceeds the maximum number. A value of 0 indicates an unlimited number of unique
prefixes. When set to 0, the operation result does not return the number of unique prefixes in a
document. The default value is 1024. |
integer |
max_unique_namespaces | No | Optionally, the maximum number of unique XML namespace URIs that the parse operation accepts.
This limit counts all XML namespaces, regardless of how many prefixes are used to declare them.
Enter a value in the range 0 - 65535. A document is rejected when the number of unique namespaces in
the document exceeds the maximum number. A value of 0 indicates an unlimited number of unique
namespaces. When set to 0, the operation result does not return the number of unique namespaces in a
document. The default value is 1024. |
integer |
max_number_length | No | Optionally, the maximum number of bytes in the value portion of a JSON label-value pair when
the value is a number. The number must be a contiguous string of bytes that contain no white space.
The number can include a minus sign and a positive or negative exponent. Enter a value in the range
0 - 256. A document is rejected when the number length in the document exceeds the maximum length. A
value of 0 indicates unlimited number length. When set to 0, the operation result does not return
the number length in a document. The default value is 128. |
integer |
strict-utf8-encoding | No | For JSON documents, whether to enforce strict UTF-8 encoding throughout the entire document.
The default value is |
boolean |
|
No | A literal string as serialized XML or JSON properties that are merged into the dynamic object. These properties take preference over any existing default properties. | string |
|
No | A URL that represents a named context from which to retrieve the serialized XML or JSON properties that are merged into the dynamic object. These properties take preference over any existing literal or default properties. | string |
input | No | The name of a variable in the API context. The content of the body field of
the variable is the input to the policy. The default variable name is
message . |
string |
output | No | The name of a variable in the API context. The content of the body field of the variable is the output of the parse operation. The parse metrics of the parsed document can be stored in a different part of the message. The default variable name is the same as the input name, so by default the input message is overwritten by the output message. | string |
parse policy example
- parse:
version: 2.0.0
title: my-parse-policy
use-content-type: true
parse-settings-reference:
default: my-parse
input: input-message
output: output-message
parse-settings-reference: literal example
In XML:
- parse:
version: 2.0.0
title: parse
parse-settings-reference:
default: apic-default-parsesettings
literal: <ParseSettings><DocumentType>xml</DocumentType></ParseSettings>
In JSON:
- parse:
version: 2.0.0
title: parse
parse-settings-reference:
default: apic-default-parsesettings
literal: { \"ParseSettings\" : { \"propertyName\" : propertyValue } }