# Schema

A schema is a specification the structure of data. The JSON schema provides a contract for what JSON data is required for a given application and how it can be modified. This allows for verification of the structure and data types inside a JSON object.

A JSON schema is intended to be JSON-based, so that JSON data in the form of a schema can be used to validate JSON data. In this way, it can be self descriptive.

Note: Although the JSON schema is still in draft status, there are several validators available for different programming languages.

The following code shows an example JSON schema:

    {
      "name":"Widget",
      "properties":
      {
        "sku":
        {
          "type":"number",
          "description":
    				"Stock Keeping Unit",
          "required":true
        },
        "name":
        {
          "description":
    				"Widget Name",
          "type":"string",
          "required":true
        },
        "price":
        {
          "type":"number",
          "minimum":0,
          "required":true
        },
        "labels":
        {
          "type":"array",
          "items":
          {
            "type":"string"
          }
        }
      }
    }

The schema above could be used to validate the following JSON object:

    {
      "sku": 12345,
      "name": "Hammer",
      "price": 123.45,
      "labels": ["Tools","Nails"]
    }