WSO2 EI provides support for JavaScript Object Notation (JSON) payloads in messages. The following sections describe how to work with JSON in the EI:
...
If you want to convert the JSON representation to XML before the mediation flow begins, you need to add the message builder and formatter shown below. Note that some data loss can occur during the JSON to XML to JSON conversion process.
<parameter name="passthruJsonBuilder">org.apache.synapse.commons.json.JsonBuilder</parameter>
<parameter name="passthruJsonFormatter">org.apache.synapse.commons.json.JsonFormatter</parameter>
The following builders and formatters can be enabled for JSON mapping in data services.
- <parameter name="dsJsonBuilder">
org.apache.axis2.json.gson.JsonBuilder
</parameter> - <parameter name="dsJsonFormatter">
org.apache.axis2.json.JSONMessageFormatter
</parameter>
The following builders and formatters can also enabled. Note that this is necessary for compatibility with previous versions of the EI (WSO2 ESB):
...
Parameter | Description | Default Value | ||
---|---|---|---|---|
| Preserves the namespace declarations in the JSON output in XML to JSON transformations. | false | ||
| Builds valid XML NCNames when building XML element names in XML to JSON transformations. | false | ||
| Allows primitive types in the JSON output in XML to JSON transformations. | true | ||
| The namespace prefix separation character for the JSON output in XML to JSON transformations. | The default separation character is - | ||
| Adds XML namespace declarations in the JSON output in XML to JSON transformations. | false | ||
| Disables auto primitive conversion in XML to JSON transformations. | null | ||
| Sets the JSON output to an array element in XML to JSON transformations. | true | ||
| Sets the JSON output to an xml multiple processing instruction in XML to JSON transformations. | true | ||
| Sets the XML output to an array element in XML to JSON transformations. | true | ||
| Sets the XML output to an xml multiple processing instruction in XML to JSON transformations. | false | ||
synapse.json.to.xml.processing.instruction.enabled | Enables adding processing instructions when performing JSON to XML conversions. For example, you can add processing instructions to identify array elements in JSON payloads with array indices (i.e., marked with "[ ]") and process them to XML.
|
Anchor | ||||
---|---|---|---|---|
|
...
Tip |
---|
When adding this sample schema file to the Registry, specify the Media Type as application/json. |
Code Block | ||
---|---|---|
| ||
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "getQuote": { "type": "object", "properties": { "request": { "type": "object", "properties": { "symbol": { "type": "string" } }, "required": [ "symbol" ] } }, "required": [ "request" ] } }, "required": [ "getQuote" ] } |
...