JSON Payload
TIBCO BusinessEvents can deserialize JSON payload to an event and can serialize an event to JSON.
For processing the JSON payload, you must perform these tasks; otherwise, the payload is treated as XML:
- Select the Is JSON Payload while creating a new destination. See Adding a Destination to a Channel and Destination Resource Reference.
- The event mapped to the destination, should have the destination URL in its default destination field.
Note:
- Regular payload validation rules apply as they would for default XML-based events, that is, if the namespace check fails, the payload is not set. Namespace for an XML element is part of its root element, while for JSON it is part of "attributes" node under "type".
- After a JSON payload is deserialized to an event, it is used the way an XML-based event is used.
XML and JSON Payload Examples
XML Request
<root xmlns="www.tibco.com/be/ontology/Events/Event2"> <param1>testProp</param1> <param2>123</param2> <param3>true</param3> </root>
JSON Request
{"root" : { "attributes" : { "type" : "www.tibco.com/be/ontology/Events/Event2" } , "param1" : "testProp", "param2" : "123", "param3" : "true" } }
XML Response
<Address> <street>243 Buena Vista Avenue</street> <city>Sunnyvale</city> <zip>94086</zip> </Address>
JSON Response
{"Address" : { "street" : "243 Buena Vista Avenue", "city" : "Sunnyvale", "zip" : "94086" } }
Payload Without Wrapping Elements
You can set the payload schema to send the JSON document with no wrapping elements. To exclude the wrapper and all the internal attribute elements, use the following properties:
be.http.json.rootElement.ignore
be.http.json.childAttributes.ignore
To ignore the parent element and its attributes, set the be.http.json.rootElement.ignore
property to true
and to ignore child concept attributes, set the be.http.json.childAttributes.ignore
to
true
. The default values of these properties is
false
.