Skip to main content
Build status Downloads Latest Version License

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"},
...            },
...        }},
...    }})

# Simple object creation
>>> obj = Model(foo="bar")
>>> assert obj == {"foo": "bar"}

# Nested and array are implemented
# HINT: Use add() instead of append()
>>> obj.bar.add(zaz="qux")
{'zaz': 'qux'}
>>> assert obj == {'foo': 'bar', 'bar': [{'zaz': 'qux'}]}

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

# Array have a special get_or_create() method
# to avoid dupplicates within an array
>>> obj.bar.get_or_create(zaz="xuq")
{'zaz': 'xuq'}
>>> obj.bar
[{'zaz': 'qux'}, {'zaz': 'xuq'}]
>>> obj.bar.get_or_create(zaz="xuq")
{'zaz': 'xuq'}
>>> obj.bar
[{'zaz': 'qux'}, {'zaz': 'xuq'}]

Release files for jsonschema-model 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema-model 1.4.0
File Size Uploaded
jsonschema-model-1.4.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema-model 1.4.0
File Interpreter ABI Platform
jsonschema_model-1.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.1 kB

Release files / jsonschema-model-1.4.0.tar.gz

Download URL jsonschema-model-1.4.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9d753f6899d535c0e6db74865c11d59ec57af5f969e83120f38d94efebdcc832
BLAKE2b-256 checksum
How to use checksums
fc63e785630ef276ffacb4f9ecde7c9fdccf2e3843cf61b6caa72ae07583a92e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / jsonschema_model-1.4.0-py2.py3-none-any.whl

Download URL jsonschema_model-1.4.0-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
59051eba59268ba0c1eaf1acb69d1bf84240b42b3d7b46189dd7a483b1b1458b
BLAKE2b-256 checksum
How to use checksums
02c30b3fdfbe8228256b41674d132cdf46a886bb7b6bbe24fb14da3a2440275e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page