Created
September 25, 2024 01:47
-
-
Save mschulz/4e0661edbdac4cb32d5daafed05c692d to your computer and use it in GitHub Desktop.
Validating JSON Against a Schema
This file contains hidden or 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
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