Translate JSON schemas in to StrictYAML schema.
Simple example:
{
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "string"
},
"possessions": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["age", "name", "possession"]
}
# All about the character
name: Ford Prefect
age: 42
possessions:
- Towel
from strictyamljsonschema import load_schema
from strictyaml import load
import json
Parse correctly:
print(load(yaml_snippet, load_schema(json.loads(json_schema))).data)
OrderedDict([('name', 'Ford Prefect'), ('age', 42), ('possessions', ['Towel'])])
$ pip install strictyamljsonschema