What's JSON

By Xah Lee. Date: . Last updated: .

What is JSON

JSON File Example

For example, here's a JSON:

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [],
  "spouse": null
}

Difference Between JavaScript Syntax vs JSON Syntax

JSON syntax is more strict than JavaScript object/array syntax.

String key must be double quoted

JSON does not allow extra comma at end.

JSON does not allow colon at the end.

JSON value does not allow undefined. (but null is ok)

Markup Langs