JSON to XML
Use the JSON to XML policy to convert the context payload of your API from the JavaScript Object Notation (JSON) format to the extensible markup language (XML) format.
Gateway support
Gateway | Policy version |
---|---|
DataPower® Gateway (v5 compatible) | 1.0.0 |
DataPower API Gateway | 2.0.0 |
The JSON to XML policy uses
a simple convention, based on BadgerFish, to convert your API context payload from JSON to XML. The
policy expects the JSON input to be in the same format as the BadgerFish convention, so the
structure can be rebuilt in XML. No additional configuration is required. For more information about
the BadgerFish convention, see BadgerFish.
Note: The JSON to XML policy does convert
the JSON structure
{ "a" : "hello" }
(which is not BadgerFish convention) into
<a>hello</a>
.Use the IBM® API Connect API Designer assembly view when you are creating your API definition to add a built-in policy to the flow.
The policy must be attached to the flow at the point at which you require the conversion to be performed. For example, if you need to convert a JSON-formatted request into an XML-formatted request, the policy must be attached to the request flow.
The policy reads input from the message.body
, if that context exists, otherwise
from the request.body
, and then writes the output to the
message.body
.
Note: If you are using the DataPower API Gateway, the input to the
JSON to XML policy must be
parsed data. One way to produce parsed data is to use a Parse policy before a JSON to XML
policy in your assembly flow, which provides explicit control of the parse action.