JSON Basics

Coding Basics - JavaScript Native Interface (JSNI)

Many AJAX application developers have adopted JSON as the data format of choice for server communication. It is a relatively simple format based on the object-literal notation of JavaScript.

The JSON format is based on the syntax and data types of the JavaScript language. It supports strings, numbers, booleans, and null values. You can also combine multiple values into arrays and objects. JSON objects are simply unordered sets of name/value pairs, where the name is always a string and the value is any other valid JSON type (even another object). Here's an example of encoding product data in JSON:

{
  "event": {
    "name": "Web2Cal Training",
    "description": "Basics of Web2Cal Integration",
    "eventId": "322",
    "members": [
      { "name": "Andy Dorman", "age": 24 },
      { "name": "Paul Smith", "age": 30 },
      { "name": "Sandy Smith", "age": 28 }     ]
  }
}

See json.org/example.html for more JSON examples.