JSON XML Transformation

Functions to transform JSON XML messages.

TIBCO API Exchange Gateway can handle non-XML request and response messages, and provide XSLT extension functions to handle non-XML message serializations.

Using the mapping feature of TIBCO API Exchange Gateway, you can transform the messages as follows:

  • Request message from one message format to other format using the forward mapper. For example, use the northbound forward mapper to modify the JSON request to an XML request. See BookQueryBE Example Request Message.
  • Response message from one message format to other format using the reverse mapper. For example, use northbound reverse mapper to modify the XML response message format to a JSON response message format. See BookQuery Example Response Message.

To support the JSON XML message transformations, TIBCO API Exchange Gateway provides the following options:

JSON Extension

The JSON extension is defined in the namespace http://www.tibco.com/asg/functions/json

XSLT Functions

TIBCO API Exchange Gateway provides the following two functions:

  • parse()

    The parse() function converts the JSON message format to XML message format.

  • render()

    The render() function converts the XML message format to JSON message format.

Note: The XML message format has a 1-to-1 correspondence with the JSON structure.

JSON Schema

TIBCO API Exchange Gateway provides the following built-in schema for JSON message:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:json="http://www.tibco.com/asg/content-types/json"
targetNamespace="http://www.tibco.com/asg/content-types/json"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="json_xml">
<xs:complexType>
<xs:sequence>
<xs:element ref="json:list"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="list">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="json:text"/>
<xs:element ref="json:double"/>
<xs:element ref="json:list"/>
<xs:element ref="json:dict"/>
</xs:choice>
<xs:attribute name="key" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="text">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="key" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="double">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="key" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="dict">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="json:text"/>
<xs:element ref="json:double"/>
<xs:element ref="json:list"/>
</xs:choice>
<xs:attribute name="key" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>