JSON (see http://www.json.org) is described as a "lightweight data-interchange format." This means that you can transfer data without much overhead. In fact, even though the XMLHTTPRequest object only contains built in support for plain text and XML, getting started with a JSON implementation is as simple as one line of code.
The ease of implementation and its lightweight nature make JSON an attractive choice for many PHP developers.
In this section we rewrite the example from the previous "Serving XML" section to use JSON instead. There is very little new code to introduce here, but we do go over the JSON concepts in depth.
JSON is very good at transferring two types of data. These two main types are arrays and objects. In XML, we had a root element that can contain numerous sub elements. These elements were collectively called nodes. In JSON, the two structures closely model the programming language that they are implemented in. Instead of nodes, we have data structures.
The first type of data structure we will study is an array. ...