JSONSchema Spec with object-oriented paths
Project description
About
Object-oriented JSONSchema
Key features
Traverse schema like paths
Access schema on demand with separate dereferencing accessor layer
Installation
pip install jsonschema-path
Alternatively you can download the code and install from the repository:
pip install -e git+https://github.com/p1c2u/jsonschema-path.git#egg=jsonschema_path
Usage
>>> from jsonschema_path import SchemaPath
>>> d = {
... "properties": {
... "info": {
... "$ref": "#/$defs/Info",
... },
... },
... "$defs": {
... "Info": {
... "properties": {
... "title": {
... "$ref": "http://example.com",
... },
... "version": {
... "type": "string",
... "default": "1.0",
... },
... },
... },
... },
... }
>>> path = SchemaPath.from_dict(d)
>>> # Stat keys
>>> "properties" in path
True
>>> # Concatenate paths with /
>>> info_path = path / "properties" / "info"
>>> # Stat keys with implicit dereferencing
>>> "properties" in info_path
True
>>> # Concatenate paths with implicit dereferencing
>>> version_path = info_path / "properties" / "version"
>>> # Open content with implicit dereferencing
>>> with version_path.open() as contents:
... print(contents)
{'type': 'string', 'default': '1.0'}
License
Copyright (c) 2017-2022, Artur Maciag, All rights reserved. Apache-2.0
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_path-0.3.1.tar.gz
(11.6 kB
view details)
Built Distribution
File details
Details for the file jsonschema_path-0.3.1.tar.gz
.
File metadata
- Download URL: jsonschema_path-0.3.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07ea584b5c9b41a614b4d011c5575955676f48d0abbfd93d9ea8e933018d716d |
|
MD5 | 0bcf052c46071e3da830d58b6a81d862 |
|
BLAKE2b-256 | 9291fbdab127309e70d60945ebec5ada96f5b2ff3c7f06011217d4e5eb6c56bf |
Provenance
File details
Details for the file jsonschema_path-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: jsonschema_path-0.3.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06f01b1848a28963f49a17730e11204d252aa6ff5db4ef84ec77e5ac93cfa831 |
|
MD5 | 426230432805557d56ad86fec94689cf |
|
BLAKE2b-256 | 73922234549efe32f6275c945d04f2da1392a47f5cd8e31ce9430366de6d4290 |