JSON or XML Serialization

The most‑common way to provide an object for a PUT or POST request is to include it in the body of the HTTP request, usually serialized into JSON or sometimes into XML format. You can use the JadeRestRequest class addObjectParam method to serialize an object into JSON or XML format, depending on the value of the value of the dataFormat property of that JadeRestRequest. For example, the following code fragment serializes the Customer object theCustomer into JSON format and adds it to the body of the JadeRestRequest object myRequest.

myRequest.dataFormat := JadeRestRequest.DataFormat_JSON;
myRequest.addObjectParam(theCustomer, Customer);

Alternatively, to serialize it into XML format, simply change the data format, as shown in the following code fragment.

myRequest.dataFormat := JadeRestRequest.DataFormat_XML;
myRequest.addObjectParam(theCustomer, Customer);