Skip to main content

jsonschemaextractor

An extension to JSON schema allowing extracting values from objects declaratively by specifying them in the schema.

Installation

pip install jsonvalidatingschemaextractor

Usage

To extract a value from a JSON object into a field, specify an extract_to property in the JSON schema which contains the name with which the value should be extracted into the resulting dictionary.

In the example below, we extract the name field in the JSON to a username field in the dictionary.

from jsonschema.validators import Draft7Validator
from jsonvalidatingschemaextractor import Extractor

schema = {
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "extract_to": "username"
        }
    }
}

validator = Draft7Validator(schema=schema)
extractor = Extractor(validator=validator)  # noqa
result = extractor.validate_and_extract({"name": "John Doe"})

assert result.extracted_values == {"username": "John Doe"}

Metadata

Release files for jsonvalidatingschemaextractor 0.1.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 jsonvalidatingschemaextractor 0.1.0
File Size Uploaded
jsonvalidatingschemaextractor-0.1.0.tar.gz 1.6 kB Details

Built distribution (wheel)

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

Total release size: 3.9 kB

Release files / jsonvalidatingschemaextractor-0.1.0.tar.gz

Download URL jsonvalidatingschemaextractor-0.1.0.tar.gz
Size 1.6 kB
Tags Source
SHA-256 checksum
How to use checksums
86ad826c991f730f27c03769155383ea5f0aca5205b5856e4b2f16386d3afbb5
BLAKE2b-256 checksum
How to use checksums
94b5fd156b2531f0df50a0bba013d1f846edffffc91ba909c72b455ebfba7801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/25.0.0

Release files / jsonvalidatingschemaextractor-0.1.0-py3-none-any.whl

Download URL jsonvalidatingschemaextractor-0.1.0-py3-none-any.whl
Size 2.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d84bd2fb64eb7666809056fbd8abb7cf2c1fc3d67dc3101e6ad870cf4e64104b
BLAKE2b-256 checksum
How to use checksums
d84816d21ef7ea1308bf86cc5e663ce63017c8c76ecebe1e879fe2fc7429b820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/25.0.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

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