IBM Integration Bus, Version 10.0.0.2 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS


Modeling a JSON object and a JSON array for use in a message map by using a schema model

In the Graphical Data Mapping editor, you can use the Cast function to create a JSON object or a JSON array.

Procedure

Comply with the following rules before you create a JSON object or a JSON array:

Example

JSON object example

In this example, the name-value pair that describes a JSON object is represented by the following code:
"FirstName":"John"
The following code represents the XML schema model that you can use to define the JSON object:
<xsd:element name="Name" type="xsd:string" nillable="true"></xsd:element>

JSON array example

In this example, the following code describes the JSON array
[{"ID": "123","Country": "US"},
           {"ID": "124","Country": "UK"},    
           {"ID": "125","Country": "Japan"}
          ]
The following code represents the XML schema model that you can use to define the JSON array:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://www.ibm.com/iib/msl/json"
    targetNamespace="http://www.ibm.com/iib/msl/json">

   <xsd:complexType name="JSONArray_MyObjType"> 
    <xsd:sequence>
        <xsd:element name="Item" type="tns:MyObjType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
    </xsd:sequence>
   </xsd:complexType>

    <xsd:complexType name="MyObjType">
      <xsd:sequence>
         <xsd:element name="ID" type="xsd:string"></xsd:element>
         <xsd:element name="Country" type="xsd:string"></xsd:element>
         </xsd:sequence>
      </xsd:complexType>
 </xsd:schema>

What to do next

Create the schema model for a JSON object or a JSON array. For more information, see Ways to create message models.


sm12024_.htm | Last updated 2015-09-24 12:54:59