Datasheet
Objects are defined in JSON like this:
{
“title” : “Flickr Mashups”,
“author” : “David Wilkinson”,
“isbn” : “0470097744”
}
Each object is surrounded by braces and within those is a comma-separated list of elements. Each element
in the object has a name and a value, separated by a colon.
Lists are comma-separated and enclosed by square brackets:
[“red”, “green”, “blue”]
[1, 2, 3, 4, 5]
[“cat”, 312, true]
The values represented in JSON may be strings (enclosed in double-quotes as shown above), numbers,
Boolean values (
true and false), or the keyword null. Whitespace that isn’t part of a string is not
significant.
Objects and arrays can be combined to form more complex data structures. For example, the data used
in the sample XML document shown earlier in this chapter could be represented in a JSON structure as a
list of objects — like this:
[
{
“title” : “Flickr Mashups”,
“author” : “David Wilkinson”,
“isbn” : “0470097744”
},
{
“title” : “Google Maps Mashups”,
“author” : “Virender Ajmani”,
“isbn” : “0470097752”
},
{
“title” : “del.icio.us Mashups”,
“author” : “Brett O’Connor”,
“isbn” : “0470097760”
},
{
“title” : “Amazon.com Mashups”,
“author” : “Francis Shanahan”,
“isbn” : “0470097779”
},
{
“title” : “Yahoo! Maps Mashups”,
“author” : “Charles Freedman”,
“isbn” : “0470097787”
}
]
13
Chapter 1: Rewriting the Web
05_097748 ch01.qxp 12/14/06 5:53 PM Page 13