Skip to content

Instantly share code, notes, and snippets.

@mschulz
Created September 25, 2024 01:47
Show Gist options
  • Save mschulz/4e0661edbdac4cb32d5daafed05c692d to your computer and use it in GitHub Desktop.
Save mschulz/4e0661edbdac4cb32d5daafed05c692d to your computer and use it in GitHub Desktop.
Validating JSON Against a Schema
from jsonschema import validate
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"}
},
}
data = {"name": "Alice", "age": 25}
validate(instance=data, schema=schema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment