Book Image

Practical Web Development

By : Paul Wellens
Book Image

Practical Web Development

By: Paul Wellens

Overview of this book

Table of Contents (23 chapters)
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
10
XML and JSON
Index

JSON


JavaScript Object Notation (JSON) is the other data interchange format discussed in this chapter. Like XML, it is text-based and human readable, but it also more lightweight than its counterpart. Data sent in the JSON format will take up a lot less bandwidth when data is sent over a network connection. It is used more and more in web applications today. XML files are heavier - just notice how many pages we needed to provide some examples, and requires a parser of some sort to process the data.

JSON is derived from JavaScript, and JSON code looks a lot like JavaScript objects, but there are subtle differences. However, JavaScript can be used to process JSON data, so you would not need a separate parser, as is the case with XML. Here is the same data from the california.xml example, but in the JSON format:

[
   {
    "name":"Adams",
     "first":"Ansel",
     "profession":"photographer",
     "born":"San Francisco"
  },
  {
    "name":"Muir",
     "first":"John",
     "profession":"naturalist...