Skip to content

Instantly share code, notes, and snippets.

@BGR360
Last active May 16, 2016 16:11
Show Gist options
  • Save BGR360/931454c143c1927fe74b to your computer and use it in GitHub Desktop.
Save BGR360/931454c143c1927fe74b to your computer and use it in GitHub Desktop.
A sample JSON schema for my research project
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Evacuation JSON",
"type": "array",
"items": {
"title": "Residential Zone",
"description": "For simple testing, this does not necessarily have to represent a residential zone",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a residential zone",
"type": "string"
},
"name": {
"description": "A more useful name for a residential zone",
"type": "string"
},
"location": {
"description": "The latitude-longitude center of the residential zone",
"type": "array",
"minItems": 2,
"maxItems": 3,
"items": {
"type": "number"
}
},
"routes": {
"description": "A list of all the routes that this residential zone can take out of the city",
"type": "array",
"items": {
"title": "Route",
"description": "A specification of a route that this residential zone can follow",
"type": "object",
"properties": {
"id": {
"description": "A unique identifier for the route. The uniqueness need only hold within this residential zone.",
"type": "string"
},
"intersections": {
"description": "A list of integer ids that refer to intersections in a RoadGraph",
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 2
},
"roadSegments": {
"description": "A list of integer ids that refer to road segments in a RoadGraph",
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
},
"batches": {
"description": "A list of batches of people that will leave at a specific time, following this route",
"type": "array",
"items": {
"title": "Batch",
"description": "A group of people that is scheduled to follow a certain route at a certain time",
"type": "object",
"properties": {
"startTime": {
"description": "An ISO-8601 string specifying the starting time of this batch (when they begin leaving)",
"type": "string",
"format": "date-time"
},
"numCars": {
"description": "The total number of cars that are in this batch",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true
},
"every": {
"description": "Specifies that one car will leave every x seconds",
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
}
},
"required": ["startTime", "numCars", "every"]
}
}
},
"required": ["id", "batches"],
"oneOf": [
{
"required": ["intersections"]
},
{
"required": ["roadSegments"]
}
]
}
}
},
"required": ["id", "routes"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment