Overview of the JSON schema format
The following code defines a basic JSON file.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"Contact" : {
"type" : "object",
"properties" : {
"FirstName":
"type": "string"
},
"Addresses" : {
"type" : "array",
"items" : {
"type" : "object",
"$ref" : "#/definitions/Address"
}
}
}
},
"Address" : {
"type" : "object",
"properties" : {
"AddressLine1" : {
"type" : "string"
},
"State" : {
"type" : "string",
"x-gw-type" : "typekey.State"
}
}
}
}
}
In this example, the various JSON property have the following meanings.
- definitions
- The
definitionssection is itself an object that contains keys for each type that it defines. Each definition has apropertiesproperty that contains keys for each allowed property. - properties
- Each property defines its own type. The type must be one of the following:
arraybooleanintegernumberobjectstring
{
"FirstName" : "Homer",
"Addresses" : [
{
"AddressLine1" : "100 Evergreen Terrace",
"State" : "MI"
}
]
}