HOME

Here you'll find some general information about the site JSON Schema

About this site

This site is intended to be a complete and understandable guide to JSON Schema. You can find an exhaustive specification with intuitive examples. The people behind this project form part of the Computer Science Department at PUC Chile, and belong to the Center for Semantic Web Research.


What is JSON?

JSON (JavaScript Object Notation) is a file format commonly used for sharing information over the Web. JSON files are lightweight and easy to read both by machines and developers. This has made JSON the most popular file format for client-server communication. The next example JSON file contains information about the famous Chilean football player Alexis Sanchez.

alexis_sanchez.json

{
    "first_name": "Alexis",
    "last_name": "Sanchez",
    "age": 27,
    "club": {
        "name": "Arsenal FC",
        "founded": 1886
    } 
}

What is JSON Schema?

A JSON Schema is a file that specifies the structure of JSON documents used by a certain application. For example, when sharing information about football players, one would like to ensure that a JSON document corresponding to a player has a given structure. A JSON Schema is a JSON document in which some words (keywords) have a predefined meaning. The next example schema specifies documents like alexis_sanchez.json.

player_schema.json

{
    "type": "object",
    "properties": {
        "first_name": { "type": "string" },
        "last_name": { "type": "string" },
        "age": { "type": "integer" },
        "club": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "founded": { "type": "integer" }
            },
            "required": ["name"]
        }
    },
    "required": ["first_name", "last_name", "age", "club"]
}


Intuitively, using this schema we are saying that our JSON documents have to have a property "first_name" with a string value, a property "last_name" and so on. Additionally, we also require that some of the information, like "first_name", "last_name", "age" and "club" details are present in each document conforming to the schema, while other properties may be ommited.

Why to use JSON Schema

There are several reasons to use a schema when storing data or sharing data over the Web. Some of the benefits: