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"}, ... }, ... }}, ... }}) # 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'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonschema-model-1.2.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for jsonschema_model-1.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f5ed0e2ede9c000391bec3b2d6b2a076f64f335ebdd346c88fb8baf8bf2b10 |
|
MD5 | e4aa549b444f53c1fcf0ee2267358ea9 |
|
BLAKE2b-256 | e12df4afee0185747dad42cdec16182842df44c62bcfe06ddd376307f7baebc2 |