Information Technology Reference
In-Depth Information
parent resource, zero or more method elements, and zero or more
resource elements.
Method describes the input to and output from an HTTP protocol
method that may be applied to a resource. A method element might
have two child elements: a request element that describes the input
to be included when applying an HTTP method to a resource and
a response element that describes the output that results from per-
forming an HTTP method on a resource. A request element might
contain query variable elements.
Representation describes a representation of the state of a resource
and can either be declared globally as a child of the application ele-
ment, embedded locally as a child of a request or response element,
or referenced externally.
Fault is similar to a representation element in structure but differs in
that it denotes an error condition.
7.4.3.2 Data Exchange for RESTful Services
Data exchange is one important aspect in any communication between dis-
tinct applications. Just as any other kind of service, RESTful services can
be seen as applications or software entities that can be accessed over the
Internet. There are two existing approaches to exchange data to and from
RESTful services, namely, JSON, a lightweight computer data interchange
format, and XML, a general language for sharing structured data between
information systems.
JSON, short for JavaScript Object Notation, is a lightweight computer data
interchange format, easy for humans to read and write, and, at the same time,
easy for machines to parse and generate. Another key feature of JSON is that
it is a completely language independent. Programming in JSON does not raise
any challenge for programmers experienced with the C family of languages.
Though XML is a widely adopted data exchange format, there are several
reasons for preferring JSON to XML:
• Data entities exchanged with JSON are typed, while XML data are
typeless (some of the built-in data types available in JSON are string,
number, array, and Boolean); XML data, on the other hand, are all
strings.
• JSON is lighter and faster than XML as on-the-wire data format.
• JSON integrates natively with JavaScript, a very popular pro-
gramming language used to develop applications on the client
side; consequently, JSON objects can be directly interpreted in
JavaScript code, while XML data need to be parsed and assigned
to variables through the tedious usage of DOM APIs (Document
Object Model APIs).
Search WWH ::




Custom Search