SetJsonObject method: Message class

Syntax

SetJsonObject(&json)

Description

Use the SetJsonObject method to load a nonrowset-based message with data from an JSON object.

Note:

This method can only be used for nonrowset-based message. If you use this method with a rowset-based message an error message is returned.

Parameters

Parameter Description

&json

Specify an already instantiated, populated JSON object.

Returns

None.

Example

&MSG = CreateMessage(Message.FLIGHTINFORMATION_CONSUME_POST);

&DOC = &MSG.GetURIDocument();
&COM = &DOC.DocumentElement;

&COM.GetPropertyByName("state").Value = "Washington";
&COM.GetPropertyByName("city").Value = "Redmond";
&MSG.URIResourceIndex = 1;
&bRet = &MSG.IBInfo.LoadRESTHeaders();

&jReqObj = CreateJsonObject();

&jOutArray = CreateJsonArray();
&jOutArray.AddElement("flight cold");
&jOutArray.AddElement("flight hot");
&jOutArray.AddElement("flight just right");

&jReqObj.AddProperty("version", "1.0");
&jReqObj.AddProperty("title", "list of flight info");
&jReqObj.AddProperty("flight", &jOutArray);

&MSG.SetJsonObject(&jReqObj);

&return_mesage = %IntBroker.SyncRequest(&MSG);