Supported Resource Representations
OneData REST services allow you to use XML and JSON resource representations. The REST API request header Content-Type=application/resource type determines if XML or JSON is the REST resource type. The default resource type is xml, change this value to json for JSON REST APIs.
In OneData, both XML and JSON REST APIs support all OneData object types, with the exception of multi-select and supertype subtype structures.
The data types supported in XML and JSON REST APIs are:
Data Type | Payload in XML String Format | Payload in JSON Format |
Boolean | "NRI" : "true" | "NRI" : true |
Char | "Code" : "IND" | "Code" : "IND" |
Date | "DOB" : "11.11.2016" | - |
Decimal | "CGPA" : "9.82" | "CGPA" : 9.82 |
Numeric | "ID" : "1001" | "Id" : 1001 |
String | "Name" : "John" | "Name" : "John" |
Timestamp | "FlightTime": "01.02.2016 11:11:11.999999999" | - |
Advantages and Limitations of JSON Over XML REST APIs
Being more easy to parse, JSON is generally preferred over the XML resource representation. Compared to XML, the JSON payload is easily and accurately processed under the following conditions:
When no XML name exists, multiple entities in an object hierarchy can have identical column names.
Simple tags appear after complex tags.
Complex hierarchies with demoralization issues.
When no
returnColumns are specified for conceptual objects, the response to the JSON request maintains the hierarchical structure of the payload format. Whereas the XML output included denormalized data which was difficult to correlate to the payload format.
However, when using JSON REST APIs, consider the following limitations that are not applicable to XML REST APIs. JSON requests do not support:
The exception queue, because
OneDatadoes not support the REST parameter
partialCommit=true.
Service audit columns, because the property
onedata.webservice.rest.responseLogLevel is not currently supported.
Prefixing the
XML Element Name to the object columns. Whereas this is available for XML requests with the use of the
onedata.webservice.rest.objectNamePrefixedInXSD property.
BLOB data type, but supports all other
OneData data types.
CLOB data type, except in insert operations.