In the Graphical
Data Mapping editor,
you can use the Add User-Defined function
to create a JSON object.
About this task
If you have a JSON schema
for your message data, you can use that as described in Creating or transforming a JSON message by using a JSON schema. Alternatively, you can model a JSON
object in your message map by following these steps:
Procedure
To create a JSON object message with one name-value pair,
complete the following steps:
- Right-click any, and select Add User-Defined.
You can see element1 created
under the any element.
- Click element1 and enter the name
of the JSON element.
For example, enter Message for
the following JSON message:
{"Message":"Hello World"}
- Select the data type of the JSON element. You can select
any of the following simple data types:
- Anonymous: Use this type to define a JSON object.
- Boolean
- date
- dateTime
- decimal
- double
- duration
- float
- hexBinary
- int
- long
- string
- time
- Global type, that is, a type based on an XML schema, a DFDL
schema, or a message set. (You access your global types by selecting
the option Browse.)
To set the type, select the user-defined element. Then,
complete one of the following steps:
- In the map, click the type of the user-defined element to open
the Type Selection window. Then, choose the type
of the element.
- In the Properties page, select the properties
page drop-down to choose the type of the element.
- In the Properties page, click Browse to
open the Type Selection window. Then, choose
the type of the element.
When you change the type to Anonymous,
the Graphical
Data Mapping editor adds a child
element.
- Select a transform. For example, use an Assign transform
to set the fixed value of a simple element.
- Set the value of the element in the Properties view. In
the General tab, enter a value in the Value property.
For example, enter Hello world to
set the value of the element Message.
Results
You create a simple JSON object message with one name-value
pair.
The message tree for the following
JSON message
{"Message":"Hello world"}
is described
in the following trace:
Message: ( ['json' : 0xc552990]
(0x01000000:Object ):Data = (
(0x03000000:NameValue):Message = 'Hello World' (CHARACTER)
)
What to do next
Deploy the message map and verify that the output
message is valid. For more information, see Troubleshooting a message map.