description |
---|
This page provides the technical details of the XML to JSON policy |
You can use the xml-json
policy to transform XML content into JSON content.
Functional and implementation information for the xml-json
policy is organized into the following sections:
{% hint style="warning" %} This policy can be applied to v2 APIs, v4 HTTP proxy APIs, and v4 message APIs. It cannot be applied to v4 TCP proxy APIs. {% endhint %}
{% tabs %} {% tab title="HTTP proxy API example" %} Example request configuration:
{
"name": "Xml to Json",
"description": "",
"enabled": true,
"policy": "xml-json",
"configuration": {}
}
{% endtab %}
{% tab title="Message API example" %} Example subscribe configuration:
{
"name": "Xml to Json",
"description": "",
"enabled": true,
"policy": "xml-json",
"configuration": {}
}
{% endtab %} {% endtabs %}
The phases checked below are supported by the xml-json
policy:
v2 Phases | Compatible? | v4 Phases | Compatible? |
---|---|---|---|
onRequest | false | onRequest | false |
onResponse | false | onResponse | false |
onRequestContent | true | onMessageRequest | true |
onResponseContent | true | onMessageResponse | true |
The xml-json
policy can be configured with the following options:
Property | Required | Description | Type | Default |
---|---|---|---|---|
scope | true | The execution scope (request or response ). | string | RESPONSE |
The following is the compatibility matrix for APIM and the xml-json
policy:
Plugin Version | Supported APIM versions |
---|---|
1.x | 3.x |
2.x | 4.0+ |
HTTP status code | Message |
---|---|
500 | The transformation cannot be executed properly |
To limit the processing time and memory consumption in case of nested object, a default max depth of nested object has been defined to 100. This default value can be overridden using the environment variable gravitee_policy_xmljson_maxdepth
.
{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-xml-json/blob/master/CHANGELOG.md" %}