json-structure 0.7.0
pip install json-structure
Released:
Validators for JSON Structure schemas and instances
Navigation
Verified details
These details have been verified by PyPIProject links
GitHub Statistics
Maintainers
๐ Avatar for clemensv from gravatar.comclemensv
Unverified details
These details have not been verified by PyPIProject links
Meta
-
License Expression: MIT
SPDX License Expression - Author: JSON Structure Project
- Tags json , json-structure , schema , type-system , validation
- Requires: Python >=3.8
-
Provides-Extra:
dev
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
- Typing
Project description
JSON Structure Python SDK
๐ PyPI version
๐ Python
๐ License: MIT
Python validators for JSON Structure schemas and instances.
JSON Structure is a type-oriented schema language for JSON, designed for defining data structures that can be validated and mapped to programming language types.
Installation
pipinstalljson-structure
Quick Start
Validate a Schema
fromjson_structureimport SchemaValidator schema = { "$schema": "https://json-structure.org/meta/core/v0/#", "$id": "https://example.com/person", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"}, "email": {"type": "string"} }, "required": ["name"] } validator = SchemaValidator() errors = validator.validate(schema) if errors: print("Schema is invalid:") for error in errors: print(f" - {error}") else: print("Schema is valid!")
Validate an Instance
fromjson_structureimport InstanceValidator schema = { "$schema": "https://json-structure.org/meta/core/v0/#", "$id": "https://example.com/person", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"} }, "required": ["name"] } instance = { "name": "Alice", "age": 30 } validator = InstanceValidator(schema) errors = validator.validate_instance(instance) if errors: print("Instance is invalid:") for error in errors: print(f" - {error}") else: print("Instance is valid!")
Features
Supported Types
All 34 types from JSON Structure Core v0 are supported:
Primitive Types:
string,number,integer,boolean,nullint8,uint8,int16,uint16,int32,uint32int64,uint64,int128,uint128(string-encoded)float8,float,double,decimaldate,datetime,time,durationuuid,uri,binary,jsonpointer
Compound Types:
object,array,set,map,tuple,choice,any
Extensions
- Conditional Composition:
allOf,anyOf,oneOf,not,if/then/else - Validation Addins:
minimum,maximum,minLength,maxLength,pattern, etc. - Import Extension:
$import,$importdefsfor schema composition
Command Line Tools
# Validate a schema file json-structure-checkschema.json # Validate an instance against a schema json-structure-validateinstance.jsonschema.json
API Reference
SchemaValidator
fromjson_structureimport SchemaValidator validator = SchemaValidator( allow_dollar=False, # Allow '$' in property names allow_import=False, # Enable $import/$importdefs import_map=None, # Dict mapping URIs to local files extended=False, # Enable extended validation features external_schemas=None # List of schema dicts to sideload (matched by $id) ) errors = validator.validate(schema_dict, source_text=None)
InstanceValidator
fromjson_structureimport InstanceValidator validator = InstanceValidator( root_schema, # The JSON Structure schema dict allow_import=False, # Enable $import/$importdefs import_map=None, # Dict mapping URIs to local files extended=False, # Enable extended validation features external_schemas=None # List of schema dicts to sideload (matched by $id) ) errors = validator.validate_instance(instance)
Sideloading External Schemas
When using $import to reference external schemas, you can provide those schemas
directly instead of fetching them from URIs:
fromjson_structureimport InstanceValidator # External schema that would normally be fetched from https://example.com/address.json address_schema = { "$schema": "https://json-structure.org/meta/core/v0/#", "$id": "https://example.com/address.json", "name": "Address", "type": "object", "properties": { "street": {"type": "string"}, "city": {"type": "string"} } } # Main schema that imports the address schema main_schema = { "$schema": "https://json-structure.org/meta/core/v0/#", "$id": "https://example.com/person", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "address": {"type": {"$ref": "#/definitions/Imported/Address"}} }, "definitions": { "Imported": { "$import": "https://example.com/address.json" } } } # Sideload the address schema - matched by $id validator = InstanceValidator( main_schema, allow_import=True, external_schemas=[address_schema] ) instance = { "name": "Alice", "address": {"street": "123 Main St", "city": "Seattle"} } errors = validator.validate_instance(instance)
You can supply multiple schemas to satisfy multiple imports. The schemas are matched
by their $id field against the import URIs.
Development
# Clone the repository gitclonehttps://github.com/json-structure/sdk.git cdsdk/python # Install development dependencies pipinstall-e".[dev]" # Run tests pytest # Run tests with coverage pytest--cov=json_structure--cov-report=term-missing
License
MIT License - see LICENSE for details.
Links
Project details
Verified details
These details have been verified by PyPIProject links
GitHub Statistics
Maintainers
๐ Avatar for clemensv from gravatar.comclemensv
Unverified details
These details have not been verified by PyPIProject links
Meta
-
License Expression: MIT
SPDX License Expression - Author: JSON Structure Project
- Tags json , json-structure , schema , type-system , validation
- Requires: Python >=3.8
-
Provides-Extra:
dev
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
- Typing
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_structure-0.7.0.tar.gz.
File metadata
- Download URL: json_structure-0.7.0.tar.gz
- Upload date:
- Size: 44.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51e2cf5cf4df3696cd34f7f6022752f2c4bf9771787514f22d028aff368caa2c
|
|
| MD5 |
6dcd7bb341af01e09c8488dcec520348
|
|
| BLAKE2b-256 |
1274be027c562d078c35b18c2db5de4b8ddd8ce7d10c7c083ed7e089690b0549
|
Provenance
The following attestation bundles were made for json_structure-0.7.0.tar.gz:
Publisher:
python.yml on json-structure/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
json_structure-0.7.0.tar.gz -
Subject digest:
51e2cf5cf4df3696cd34f7f6022752f2c4bf9771787514f22d028aff368caa2c - Sigstore transparency entry: 1756335711
- Sigstore integration time:
-
Permalink:
json-structure/sdk@d0f0f6425703ba9c672d230f3d5b03865a9eaf69 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/json-structure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@d0f0f6425703ba9c672d230f3d5b03865a9eaf69 -
Trigger Event:
push
-
Statement type:
File details
Details for the file json_structure-0.7.0-py3-none-any.whl.
File metadata
- Download URL: json_structure-0.7.0-py3-none-any.whl
- Upload date:
- Size: 47.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f4b40ca6522b3111b9001488058100a21f208cd2bdc3eb1e484f0ff92d1e23c
|
|
| MD5 |
d6081e80536906b17eab1919842edec5
|
|
| BLAKE2b-256 |
d4087bc5fae5fc084abfa36172cc593c9b8ebfe7067026b7ceb5e8a26ca62b9a
|
Provenance
The following attestation bundles were made for json_structure-0.7.0-py3-none-any.whl:
Publisher:
python.yml on json-structure/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
json_structure-0.7.0-py3-none-any.whl -
Subject digest:
4f4b40ca6522b3111b9001488058100a21f208cd2bdc3eb1e484f0ff92d1e23c - Sigstore transparency entry: 1756335773
- Sigstore integration time:
-
Permalink:
json-structure/sdk@d0f0f6425703ba9c672d230f3d5b03865a9eaf69 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/json-structure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@d0f0f6425703ba9c672d230f3d5b03865a9eaf69 -
Trigger Event:
push
-
Statement type:
