In the Graphical Data Mapping editor, you can use the Add User-Defined function to create a JSON message that contains JSON objects, JSON arrays, or both.
If you have a JSON schema model, you can use it in your map in a shared library or REST API; for more information, see Creating or transforming a JSON message by using a JSON schema. If you do not have a JSON schema model, you can create a map selecting the predefined JSON message and define your JSON data by using the Add User-Defined function as described in this topic.
Complete the following steps to create a JSON message for which you do not have a schema model:
{"element1":[{"Nam":"val1","Num":1},{"Nam":"val2","Num":2}]}
(0x01000000:Object):JSON = ( ['json' : 0x2f030fa0]
(0x01000000:Object):Data = (
(0x01001000:Array):element1 = (
(0x01000000:Object):Item = (
(0x03000000:NameValue):Nam = 'val1' (CHARACTER)
(0x03000000:NameValue):Num = 1 (INTEGER)
)
(0x01000000:Object):Item = (
(0x03000000:NameValue):Nam = 'val2' (CHARACTER)
(0x03000000:NameValue):Num = 2 (INTEGER)
)
)
)
)
[{"element1":{"field1":"Sweet","field2":"Flower"},"element2":"me@bbloggs.com"}]
(0x01000000:Object):JSON = ( ['json' : 0x292051a0]
(0x01001000:Array):Data = (
(0x01000000:Object):Item = (
(0x01000000:Object ):element1 = (
(0x03000000:NameValue):field1 = 'Sweet' (CHARACTER)
(0x03000000:NameValue):field2 = 'Flower' (CHARACTER)
)
(0x03000000:NameValue):element2 = 'me@bbloggs.com' (CHARACTER)
)
)
Deploy the message map and verify that the output message is valid. For more information, see Troubleshooting a message map.