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


Creating or transforming a JSON output message by using the User Defined function to model the JSON data

You can use the Add User Defined function in the Graphical Data Mapping editor to create or transform a JSON object message or a JSON array message.

About this task

When you create a message map, you can choose to provide the model of the JSON data from a JSON schema, or you can define your JSON data by using the Add User Defined function in the map. This topic explains how to use the Add User Defined function. For information about using a JSON schema, see Creating or transforming a JSON message by using a JSON schema.

Predefined models are available under the IBM® supplied message models category in the map input and output selection tree.
  • You select JSON (JSON object message model supplied by IBM) to create a JSON object message.
  • You select JSON (JSON array message model supplied by IBM) to create a JSON array message.

When you select any of the JSON message models as the map output, the output domain in the output message assembly is automatically set to JSON.

The predefined JSON message contains a single element value of type JSONMsg_type. This element contains the following child elements:
  1. A Padding element: This element is optional. You define its value to pass a user-defined JavaScript function call used by JSONP services.
  2. Two Data elements: You define only one of the Data elements to model your JSON message.
    • You define the element Data, of type anyType, by using the Cast function. You define this element when you have a schema model that defines your JSON message. If you create your map programmatically, you can cast Data to some type in an external schema file, which can define either a JSON object or a JSON array message.
    • You define the element Data, of type JSONObject, by using the Add User-Defined function. You define this element when you want to transform some elements of your JSON object message. You can also use the Cast function to define the JSON message, or a part of it, with a schema model.

      Figure that shows the JSON object message type that is predefined in the Graphical Data Mapping editor.

    • You define the element Data, of type JSONArray_1, by using the Add User-Defined function. You define this element when you want to transform some elements of your JSON object message. You can also use the Cast function to define the JSON message, or a part of it, with a schema model.

      Figure that shows the JSON array message type that is predefined in the Graphical Data Mapping editor.

Procedure

You can complete any of the following actions on JSON messages in the Graphical Data Mapping editor:

  1. You can define a JSON object without a schema model graphically. Use the Add User-Defined function to add an element, and select one of the supported simple types. For more information, see Graphically modeling a JSON object in a message map.
  2. You can define a JSON array without a schema model graphically. All the elements in the array are of the same type. Use the Add User-Defined function to add an element, and select JSONArray_Default as its type. For more information, see Graphically modeling a JSON array in a message map.
  3. You can define a multidimensional JSON array without a schema model graphically. Use the Add User-Defined function to add multiple elements, and select JSONArray_Default as their types. For more information, see Graphically modeling a multidimensional JSON array in a message map.
  4. You can create a JSONP message, or transform a message that is modeled in a different message domain into a JSONP message. For more information, see Graphically modeling and transforming a JSONP message in a message map.
  5. You can define a JSON message by using your own schema model. Use the Cast function to add a JSON message. For more information, see Modeling a JSON message for use in a message map by using an equivalent XML schema model.
  6. You can use the Graphical Data Mapping editor to implement a REST API operation. For more information, see Implementing a REST API operation by using a message map.

sm12037_.htm | Last updated 2018-12-15 07:47:29