Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated the ESB links with EI 611 links

...

Also see the following sections in the WSO2 ESB EI documentation. WSO2 ESB EI is used to implement the API Gateway through which API messages are transformed:

JSON message builders and formatters

...

  • org.apache.axis2.json.JSONBuilder/JSONMessageFormatter
  • org.apache.axis2synapse.commons.json.JSONStreamBuilderJsonStreamBuilder/JSONStreamFormatter

  • org.apache.axis2.json.JSONBadgerfishOMBuilder/JSONBadgerfishMessageFormatter

...

Tip

To support having spaces inside JSON attributes, change the default JSON builder and formatter to the following pair in either <APIM_HOME>/repository/conf/axis2/axis2.xml (super tenant scenario) or <APIM_HOME>/repository/conf/axis2/tenant-axis2.xml (tenant scenario) file:

Code Block
<messageBuilder contentType="application/json" class="org.apache.axis2synapse.commons.json.JSONStreamBuilder>JsonStreamBuilder>
<messageFormatter contentType="application/json" class="org.apache.synapse.axis2commons.json.JSONStreamFormatter”JsonStreamFormatter”/>
Tip

To support use cases for JSON payloads with arrays, change the default JSON builder and formatter to the following pair in either <APIM_HOME>/repository/conf/axis2/axis2.xml (super tenant scenario) or <APIM_HOME>/repository/conf/axis2/tenant-axis2.xml (tenant scenario) file:

Code Block
<messageBuilder contentType="application/json" class="org.apache.axis2synapse.commons.json.JSONStreamBuilder>JsonStreamBuilder>
<messageFormatter contentType="application/json" class="org.apache.axis2synapse.commons.json.JSONStreamFormatter”JsonStreamFormatter”/>

Else, in JSON to XML conversion, there might be issues as below:

Code Block
titleJSON
"phoneNumbers":[
      {
        "phoneNumber":"4027161289",
        "phoneNumberType":"home"
      }
]
Code Block
titleConverted XML
<?xml-multiple phoneNumbers?>
<phoneNumbers>
   <phoneNumber>4027161289</phoneNumber>
   <phoneNumberType>home</phoneNumberType>
</phoneNumbers>

...

Note that we have used the Property mediator to mark the outgoing payload to be formatted as JSON. For more information about the Property Mediator, see the Property Mediator page on WSO2 ESB EI documentation.

Code Block
languagehtml/xml
<property name="messageType" value="application/json" scope="axis2"/>

...

Info
titleXML to JSON Transformation Parameters

See JSON Transformation Parameters for additional parameters for converting XML to JSON.