Database Reference
In-Depth Information
is an acronym for Java Script Object Notation, and is a convenient way to describe, serialize,
and transfer data. It's easy to learn and understand, and is easily parsable, self-describing,
and hierarchical. In addition, JSON syntax is fairly simple. Data is represented by name-
value pairs and is comma separated. Objects are enclosed by curly brackets, and arrays are
enclosed by square brackets.
JSON is often compared to XML because both are used in data description and data transfer.
While you'll find XML is perhaps a richer and more extensible method of serializing and de-
scribing data, you may also find that it is more difficult to read and parse. The Hadoop com-
munity seems to favor JSON rather than XML. That said, many of the configuration files in
the Hadoop infrastructure are written in XML, so a basic knowledge of XML is still required
to maintain a Hadoop cluster.
Tutorial Links
JSON has become one of the most widely adopted standards for sharing data. As a result,
there's a wealth of information available on the Internet, including this w3schools article .
Example Code
Our movie review data can easily be expressed in JSON.
For example, here's the original data:
Kevin,Dune,10
Marshall,Dune,1
Kevin,Casablanca,5
Bob,Blazing Saddles,9
And here's the JSON-formatted data (the reviews are described as a collection called
movieReviews , which consists of an array of a collection of name-value pairs—one for the
name of the reviewer, one for the name of the move, and one for the rating):
{
"movieReviews": [
{ "reviewer":"Kevin", "movie":"Dune", "rating","10" },
{ "reviewer":"Marshall", "movie":"Dune", "rating","1" },
{ "reviewer":"Kevin", "movie":"Casablanca", "rating","5" },
{ "reviewer":"Bob", "movie":"Blazing Saddles", "rating","9" }
Search WWH ::




Custom Search