Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 8 Using Sample Projects : The JSONSample Project

The JSONSample Project
The JSONSample project shows how to use TIBCO ActiveMatrix BusinessWorksTM Plug-in for REST and JSON to convert data between JSON and XML using normal conversion rules and Badgerfish conversion rules. In this project, the Trading Order business object is used.
Processes Description
This project contains the following predefined processes:
The JSON Badgerfish Process
The JSON Badgerfish process converts data between JSON and XML with Badgerfish conversion rules. In this process, the Generic and XSD schema types are used to construct the output data. Figure 17 shows the JSON Badgerfish process.
Figure 17 The JSON Badgerfish Process
The process contains two parallel operations:
Converting Data from XML to JSON and then Back to XML
In this operation, the following activities are processed:
1.
The Render JSON activity takes XML data, and renders it as a JSON string. The output data is structured with an XML schema file, Book_info.xsd, which is located in the RESTJSON_HOME\examples\JSONSample\Badgerfish directory.
2.
Converting JSON Strings to XML Strings
In this operation, the following activities are processed:
1.
The Read JSON activity reads a file, Book_info.json, and passes the file content to the Parse Generic activity.
The Book_info.json file is located in the RESTJSON_HOME\examples\JSONSample\Badgerfish directory.
2.
The Parse Generic activity takes the JSON string from the Book_info.json file and then converts it to an XML string.
The Trading Orders Process
The Trading Orders process converts data between JSON and XML with normal conversion rules on a trading orders business object. In this process, the XSD schema type is used to format the XML data. Figure 18 shows the Trading Orders process definition.
Figure 18 The Trading Orders Process
The process contains two parallel operations:
Converting Data from JSON to XML
In this operation, the following activities are processed:
1.
The Read Order JSON activity reads a JSON data file, BW_new_order.json, and passes the file content to the Parse JSON activity.
The BW_new_order.json file is located in the RESTJSON_HOME\examples\JSONSample\SampleData directory.
2.
The output data is structured in an XML schema file, BW_new_order.xsd, which is located in the RESTJSON_HOME\examples\JSONSample\JSON_GEN_Schemas directory.
3.
Converting Data from XML to JSON
In this operation, the following activities are processed:
1.
The Read Order XML activity reads the BW_new_order.xml data file, and passes the file content to the Parse XML activity.
The BW_new_order.xml file is located in the RESTJSON_HOME\examples\JSONSample\SampleData directory.
2.
The Parse XML activity takes the XML data from the Read Order XML activity and then converts it to an XML schema tree based on an XML schema file, BW_new_order.xsd, which is located in the RESTJSON_HOME\examples\JSONSample\JSON_GEN_Schemas directory.
3.
Setting Up the Project
Before running the project, you need to perform the following steps to set up the project in TIBCO Designer:
1.
2.
Click Open Existing Project in the TIBCO Designer startup panel. The Open Project dialog is displayed.
3.
Click Browse next to the Project Directory field and then select the JSONSample folder, which is located in the RESTJSON_HOME\examples\JSONSample directory. Click OK. The project is displayed.
4.
a.
Click the Global Variables tab in the Project panel.
b.
Click the JSON_Plugin item and then click Open Advanced Editor at the top of the left corner in this panel. The Global Variables dialog is displayed.
c.
Expand the JSON_Plugin item and then set a value for the SampleProjectDir parameter. The value should be as follows:
RESTJSON_HOME\examples\JSONSample\
d.
Click OK to save your setting.
5.
Select Project > Save from the TIBCO Designer menu to save the project.
Running the Project
After setting up the project, complete the following steps to trigger the JSON Badgerfish process or the Trading Orders process:
1.
In the Project panel, click the Tester tab and then click Start testing viewed process at the top left corner in this panel. The Select Processes To Load dialog is displayed.
2.
Select the Trading Orders check box, or expand Badgerfish and select the JSON Badgerfish check box. Click Load Selected. The process is started.
When the process executes, the elements of the process change colors depending upon what is occurring in the executing process instance. If all the transition lines change to green, it means the process runs successfully.
3.
Click Stop testing to return to the Design mode.
See TIBCO ActiveMatrix BusinessWorksTM Process Design Guide for detailed information on using the test mode including setting breakpoints and the element colors in the test mode.
Expected Results
If the processes perform successfully, the green color is displayed between each activity.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved