Open In App

JSON Schema

JSON Schema is a content specification language used for validating the structure of a JSON data.It helps you specify the objects and what values are valid inside the object’s properties. JSON schema is useful in offering clear, human-readable, and machine-readable documentation.

Structure of a JSON Schema: Since JSON format contains an object, array, and name-value pair elements. Name-value pairs are used for providing schema processing elements as well as validating the JSON content. Schema processing elements include(not limited to).



JSON content definition:

Example:



{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Voters information",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or 
                      greater than eighteen in order to vote.",
      "type": "integer",
      "minimum": 18
    }
  }
}

Output:

{
  "firstName": "Indra",
  "lastName": "Sen",
  "age": 20
}

The above JSON schema contains the following:

Article Tags :