Skip to content
Snippets Groups Projects
Commit 02e4d106 authored by Simon Wittl's avatar Simon Wittl
Browse files

Merge branch 'readme' of https://mygit.th-deg.de/roboct/definitions/json_schemas into readme

parents c6ff007a 4f641715
No related branches found
No related tags found
No related merge requests found
......@@ -31,5 +31,33 @@ This schema defines the properties for projection data in THD JSON format.
### Examples
```python:../scripts/validate_thd_json.py
from jsonschema import validate, ValidationError
import json
from pathlib import Path
SHEMA = Path('./thd_json/projection.json')
FILE = Path('./examples/thd_json/test_thd.json')
def main():
with open(str(SHEMA)) as schema_file, open(str(FILE)) as data_file:
schema = json.load(schema_file)
data = json.load(data_file)
print(f"JSON Schema: {schema['title']}")
print(f"Validate File: {FILE.parent} / {FILE.name}\n")
print(f"JSON Schema (Version): {schema['version']}")
print(f"JSON Schema (Date): {schema['date']}\n\n")
try:
validate(instance=data, schema=schema)
print("JSON is valid.")
except ValidationError as e:
print("Validation error:", e)
if __name__ == '__main__':
main()
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment