22 lines
573 B
Python
Executable file
22 lines
573 B
Python
Executable file
#!/usr/bin/env python3
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
from jsonschema import validate
|
|
|
|
if len(sys.argv) != 2:
|
|
print("Usage: valider-json.py <fichier.json>")
|
|
sys.exit(1)
|
|
|
|
base = Path(__file__).resolve().parent.parent
|
|
schema_path = base / "specification" / "schema-nqfs-1.0.json"
|
|
data_path = Path(sys.argv[1]).resolve()
|
|
|
|
with open(schema_path, "r", encoding="utf-8") as f:
|
|
schema = json.load(f)
|
|
|
|
with open(data_path, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
|
|
validate(instance=data, schema=schema)
|
|
print("JSON valide selon NQFS-1.0")
|