XML
and JSON
are both designed to form a simple and standardized way of describing different kind of
hierarchical data structures and to facilitate their transportation and consumption in a standardized way.
The Odyssee API is compatible with both formats. But there are some limitation with XML especially with ODATA (Paging and $select).
If you do not have any specific requierments, we suggest using JSON, for the following reasons:
- Light : the lenght of the message will be smaller than using XML
- Popular : you can find a lot of tools and libraries on the Internet to easily manipulate JSON objects
- OData Paging : Paging is working direclty and you have the
@odata.nextLink
field on the HTTP Result
- OData Select : ou can use the
$select
statement on the URL
Take a look at the following example:
XML :
John Crichton
male
Aeryn Sun
female
JSON :
{
"employees": [
{
"name": "John Crichton",
"gender": "male"
},
{
"name": "Aeryn Sun",
"gender": "female"
}
]
}
XML: Extensible Markup Language
- An open standard for describing data defined by the World Wide Web Consortium (W3C).
- XML lets Web developers and designers create customized tags that offer greater flexibility in organizing and presenting information.
- XML defines rules to mark-up a document in a way that allows the author to express semantic meaning in the mark-up. XML does not necessarily restrict the author to certain tags (elements) as HTML does.
- XML defines rules to mark-up a document in a way that allows the author to express semantic meaning in the mark-up. XML does not necessarily restrict the author to certain tags (elements) as HTML does.
- Internet media type:
application/xml
Because XML can include requirements that can brings bugs and make the work of developpers harder, we adapt our API to make life easier.
2 concepts on XML API are not applied here:
- Following XML Schema when doing POST/PUT
The order of the field on the XML is not important on this API.
- Namespace on XML declaration
There is no need to specify a namespace on the request body, like
...
You can avoid it , like
...
JSON: JavaScript Object Notation
- A lightweight text-based open standard designed for human-readable data interchange.
- A text-based format for exchanging objects.
- It is an alternative to XML that is more concise because, unlike XML, it is not a markup language that requires open and close tags.
- It is derived from the object literals of JavaScript.
- Design goals were for it to be minimal, portable, textual, and a subset of JavaScript.
- Internet media type:
application/json