Parse
Use the Parse policy to control the parsing of an input document.
Gateway | Policy version |
---|---|
DataPower® API Gateway | 2.0.0 |
This topic describes how to configure the policy in the assembly user interface; for details on how to configure the policy in your OpenAPI source, see parse.
About
When the input document is a JSON string, the string is parsed instead of copied over. You can
re-parse a JSON string as any of the allowed doc types (detect, xml, json, binary
).
For example, suppose that the JSON string "<a></b></a>"
is parsed. You can
re-parse it using doc type xml
to extract the XML from that string.
- Specify a valid parse settings configuration from which to retrieve its properties as the
default parse settings.Note: If you change the default name, you must separately configure a corresponding ParseSettings object on the DataPower API Gateway.
- Specify a literal string as serialized XML or JSON properties as parse settings. These
properties take precedence over any existing default properties. The literal string must be XML or
JSON formatted.
- The XML format is
"<ParseSettings><propertyName>propertyValue</propertyName></ParseSettings>"
. - The JSON format is
"{ \"ParseSettings\" : { \"propertyName\" : propertyValue } }"
.
- The XML format is
- A URL that represents a named context from which to retrieve the serialized XML or JSON properties as parse settings. These properties take precedence over any existing literal or default properties.
Properties
The following table lists the policy properties, indicates whether a property is required, specifies the valid and default values for input, and specifies the data type of the values.
Property label | Required | Description | Data type |
---|---|---|---|
Title | No | The title of the policy. The default value is |
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 action 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 action uses the Enabling this setting is applicable only when the expected
If this setting is not enabled, the parse action uses either the document type that is specified in the parse setting, or the detected document type if the parse setting is configured to detect the document type. The check box is cleared by default. |
boolean |
Parse settings object reference | No | An existing valid object from which to retrieve default property values for the dynamic object. | string |
Parse settings literal configuration | No | A literal string as serialized XML or JSON properties that are merged into the dynamic object. The literal property overrides any existing default properties. | string |
Parse settings URL reference | 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 override any existing literal or default properties. | string |
Message for parsing | 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 |
Message for resulting parsed data | 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 |