Skip to main content

Supported Python versions PyPI package version Documentation status Test status Code coverage MIT license Total downloads

A JSON toolkit for Python developers.

Features

  • JSON Schema validator implementation (drafts 2019-09, 2020-12)

    • Schema compilation and indexing

    • $ref loading from local and remote sources

    • Support for custom keywords, vocabularies and meta-schemas

    • Support for format validation

  • JSON class implementing the JSON data model

  • JSON Pointer (RFC 6901)

  • JSON Patch (RFC 6902)

  • Relative JSON Pointer (draft)

Installation

pip install jschon

For remote $ref support, the requests library is required. It may be installed with:

pip install jschon[requests]

Basic usage

Create a JSON schema:

from jschon import create_catalog, JSON, JSONSchema

create_catalog('2020-12')

demo_schema = JSONSchema({
    "$id": "https://example.com/demo",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "array",
    "items": {
        "anyOf": [
            {
                "type": "string",
                "description": "Cool! We got a string here!"
            },
            {
                "type": "integer",
                "description": "Hey! We got an integer here!"
            }
        ]
    }
})

Validate JSON data:

result = demo_schema.evaluate(
    JSON([12, "Monkeys"])
)

Generate JSON Schema-conformant output:

>>> result.output('basic')
{
    "valid": True,
    "annotations": [
        {
            "instanceLocation": "",
            "keywordLocation": "/items",
            "absoluteKeywordLocation": "https://example.com/demo#/items",
            "annotation": True
        },
        {
            "instanceLocation": "/0",
            "keywordLocation": "/items/anyOf/1/description",
            "absoluteKeywordLocation": "https://example.com/demo#/items/anyOf/1/description",
            "annotation": "Hey! We got an integer here!"
        },
        {
            "instanceLocation": "/1",
            "keywordLocation": "/items/anyOf/0/description",
            "absoluteKeywordLocation": "https://example.com/demo#/items/anyOf/0/description",
            "annotation": "Cool! We got a string here!"
        }
    ]
}

Release files for jschon 0.11.1

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

Source distribution (sdist)

Source distribution for jschon 0.11.1
File Size Uploaded
jschon-0.11.1.tar.gz 69.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jschon 0.11.1
File Interpreter ABI Platform
jschon-0.11.1-py3-none-any.whl Python 3 none any Details

Total release size: 136.4 kB

Release files / jschon-0.11.1.tar.gz

Download URL jschon-0.11.1.tar.gz
Size 69.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c0ca0beab1f1694a03d726b91ed75ec604a7787af3ae91ead765f78215bf149f
BLAKE2b-256 checksum
How to use checksums
7b8b5cbfbb4751533027ba97a59dfe4c9e694fbceaf549fa9cd7cb9a6066bd60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / jschon-0.11.1-py3-none-any.whl

Download URL jschon-0.11.1-py3-none-any.whl
Size 67.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2350e8b6747b17358022960f91208bea70de448b914827af3184d30e20500f0f
BLAKE2b-256 checksum
How to use checksums
ceb131f454a2ac0d23b0a47283d115f0af4abe2a1ea391f5ccb223e02d685b82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.11.1 This release

2 release files

0.10.3

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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