datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com  
Events
UBM Tech
UBM Tech

Design Article

Web services for smart objects - Part 1: Overview

Jean-Philippe Vasseur and Adam Dunkels

6/21/2010 2:05 PM EDT

Common Data Formats
9.1.1 Common Data Formats
Web services are a mechanism for exchanging data between disparate systems that are not developed by the same parties. The systems may be developed in different programming languages and run on vastly different hardware, but they still wish to exchange data in a system-independent way. For this reason, system-independent data formats are central to the web services framework.

The Extensible Markup Language (XML) is the most common data format associated with web services, but it is not the only data format available. In fact, the web services framework is not dependent on any particular data format, because it can operate across a range of data formats.

XML is a general purpose document format that provides a structured mechanism to encode machine-readable information. In addition to being machine-readable, XML documents are also human-readable, making them readily created and edited by humans as well as machines.

XML documents are composed of a set of tags, where each tag is shown as the name of the tag enclosed in the < and > characters. A tag consists of an open tag and a close tag. The close tag is the same as the open tag, but with the /character in front of the name. An example of a tag is <data>one</data>, where <data> opens the tag and </data> closes the tag. The value of the tag is the text between the open and close tag, which in this case is "one" . Tags are nested to form a tree of tags.

An example of an XML document is shown in Figure 9.3 . This XML document contains a temperature value from a fictional temperature sensor. The name of the sensor, "Temperature" , is given in the <name> tag and the value is given in the <value> tag. The <sensor> tag contains information about one particular sensor. In this document, only a single sensor is present but more can be added following the closing of the <sensor> tag.

Because XML is a relatively verbose format, several ways to compress XML have been explored. The structured nature of XML makes XML possible to compress using source-specific techniques, and a number of variants of XML that use binary encodings rather than textual representations of the XML tags exist. There is, however, no standard for binary XML and none of the available formats have succeeded in achieving a de facto standard status.

An alternative to the verbose XML format is the JavaScript Object Notation (JSON) format. JSON is specified in RFC4627 [45] and provides a more lightweight markup than XML. Although JSON originally was designed to be easy to parse by JavaScript programs, the format is independent of any particular programming language. Libraries for parsing and constructing JSON messages are available for most programming languages.

An example of a JSON document is shown in Figure 9.4. This document contains the same information as the XML document in Figure 9.3, but is much more compact. The markup is more lightweight, but provides less means by which the document can be automatically translated between different formats. Yet, the JSON format is a good match for smart object systems, where compactness of representation is important due to the inherent resource constraints.

{"sensors":
  [{"name": "Temperature", "value": 26.1}]
}

FIGURE 9.4 A JSON document.





Please sign in to post comment

Navigate to related information

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)