Try it on https://www.jsonschemavalidator.net/
Last active
September 21, 2018 18:02
-
-
Save bcardiff/c0191a33d7ad05dd3f74b2591aa38708 to your computer and use it in GitHub Desktop.
JSON schema sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 2, | |
"names": ["sdf","sdfs"], | |
"some_values": ["asda", 34], | |
"owner": {"first": "John", "last": "Doe"}, | |
"people": [{"first": "John", "last": "Doe"}], | |
"colors": { | |
"blue": { "hex": "#0000ff", "rgb": [0,0,255] }, | |
"red": { "hex": "#ff0000", "rgb": [255,0,0] } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"definitions": { | |
"person": { | |
"type": "object", | |
"properties": { | |
"first": { | |
"type": "string" | |
}, | |
// this is the last name of the person | |
"last": { | |
"type": "string" | |
} | |
}, | |
"required": [ | |
"first", | |
"last" | |
], | |
"additionalProperties": false | |
}, | |
"colors_by_name": { | |
"type":"object", | |
"additionalProperties": { "$ref": "#/definitions/color" } | |
}, | |
"color": { | |
"type": "object", | |
"properties": { | |
"hex": { "type": "string" }, | |
"rgb": { | |
"type": "array", | |
"items": {"type": "number"}, | |
"minItems": 3, | |
"maxItems": 3, | |
}, | |
}, | |
"additionalProperties": false, | |
"required": ["hex","rgb"] | |
} | |
}, | |
"type": "object", | |
"properties": { | |
"id": { | |
"type": "integer" | |
}, | |
"names": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
} | |
}, | |
"some_values": { | |
"type": "array", | |
"items": { | |
"oneOf": [ | |
{"type": "string"}, | |
{"type": "integer"} | |
] | |
} | |
}, | |
"people": { | |
"type": "array", | |
"items": { "$ref": "#/definitions/person" } | |
}, | |
"owner": { "$ref": "#/definitions/person" }, | |
"colors": { "$ref": "#/definitions/colors_by_name" } | |
}, | |
"required": [ | |
"id", | |
"names", | |
"people", | |
"colors", | |
"some_values" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment