Graphically modeling a JSON object in a message map

In the Graphical Data Mapping editor, you can use the Add User-Defined function to create a JSON object.

Before you begin

Create a message map with the output domain set to JSON. For more information, see Graphically modeling a JSON message in a message map

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:

  1. Right-click any, and select Add User-Defined.

    Shows the option Add User-Defined

    You can see element1 created under the any element.

    Shows the user-defined element that is created under the any element.

  2. Click element1 and enter the name of the JSON element.

    For example, enter Message for the following JSON message:

    {"Message":"Hello World"}

    Shows element1 renamed as Message under the any value.

  3. 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.

  4. Select a transform. For example, use an Assign transform to set the fixed value of a simple element.

    Shows the Assign transform wired to the Message element.

  5. 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.

    Shows the value set to Hello World for 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.