Skip to main content

Json schema Model

Project description

Build python objects using JSON schemas:

>>> import jsonschema_model
>>> Model = jsonschema_model.model_factory({
...    "name": "Model",
...    "properties": {
...        "foo": {"type": "string"},
...        "bar": {"type": "array", "items": {
...            "type": "object",
...            "name": "Bar",
...            "properties": {
...                "zaz": {"type": "string"},
...            },
...        }},
...    }})
>>> obj = Model(foo="bar")
>>> obj
{'foo': 'bar'}
>>> obj.bar.add(zaz="qux")
{'zaz': 'qux'}
>>> obj
{'foo': 'bar', 'bar': [{'zaz': 'qux'}]}

# You can access via attribute or via dict like interface
>>> obj["bar"][0].zaz
'qux'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsonschema-model, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size jsonschema-model-1.0.0.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page