![]() |
Copyright © Cloud Software Group, Inc. All Rights Reserved |
•
• The JSON extension is defined in the namespace http://www.tibco.com/asg/functions/json
• The parse() function converts the JSON message format to XML message format.
• The render() function converts the XML message format to JSON message format.
Task A Create an XSLT File
• Use the render() functionSee Example XSLT to Convert BookQuery XML Response to JSON Response for an example XSLT.Task B Upload the XSLT File
3. Add a new project or select an existing project under Projects. For example, select BookQuery project.
a. Click the MAPPING > Mapping tab.
b. Click the Add property to create a new mapping.
− Mapping Name: XML_JSON_Mapping
− Type:XSLT (select from the drop-down list.)
−
−
a.
c. In the Response Transform field, select the XML_JSON_Mapping mapper, as created in the mapping configuration from the drop-down list.When the BookQuery example is run, TIBCO API Exchange Gateway sends the response message in XML format to the client, by default.
The following is the transformed JSON response message from the XSLT defined as Example XSLT to Convert BookQuery XML Response to JSON Response.
Using the northbound forward mapper, parse the JSON encoded string to generate an XML message. Usually, the JSON data is encoded using base64 format, therefore, the data must be converted from base64 to text. TIBCO API Exchange Gateway provides the codecs:base64ToText() function to convert the json data to text.Task A Create an XSLT FileThe parse() function requires the following namespaces: http://www.tibco.com/asg/functions/json
• Use the parse() function as follows:
− Extract the base64 encoded request payload from the context document.
− Use the codecs:base64ToText() function to convert the payload to text message.
− Pass the text message to the json:parse() function.See Example XSLT to Convert BookQueryBE JSON Request to XML Request for an example XSLT.Task B Upload the XSLT File
3. Add a new project or select an existing project under Projects. For example, select the BookQueryBE project.
a. Click the MAPPING > Mapping tab.
b. Click the Add property to create a new mapping.
− Mapping Name: JSON_XML_Mapping
− Type:XSLT (select from the drop-down list.)
−
−
a.
c. In the Request Transform field, select JSON_XML_Mapping mapper, as created in the mapping configuration from the drop-down list.For example, when the BookQueryBE example is run, the client can send a request message in JSON format. This section describes how to convert the JSON data to an XML request using the json:parse() function for the BookQueryBE example.
The following is the transformed XML request message from the XSLT defined as Example XSLT to Convert BookQueryBE JSON Request to XML Request.
![]() |
Copyright © Cloud Software Group, Inc. All Rights Reserved |