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:
- A Padding element: This element is optional.
You define its value to pass a user-defined JavaScript function call used by JSONP
services.
- 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.
- 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.