Infer JSON schemas from sample data
Project description
philiprehberger-schema-infer
Infer JSON schemas from sample data.
Installation
pip install philiprehberger-schema-infer
Usage
from philiprehberger_schema_infer import infer, infer_type, merge_schemas
samples = [
{"name": "Alice", "age": 30, "active": True},
{"name": "Bob", "age": 25, "email": "bob@test.com"},
]
schema = infer(samples)
# {
# "type": "object",
# "properties": {
# "name": {"type": "string"},
# "age": {"type": "integer"},
# "active": {"type": "boolean"},
# "email": {"type": "string", "format": "email"}
# },
# "required": ["age", "name"]
# }
# Single value
infer_type([1, 2, 3])
# {"type": "array", "items": {"type": "integer"}}
# Merge schemas
merged = merge_schemas(schema_a, schema_b)
API
| Function / Class | Description |
|---|---|
infer(samples) |
Infer JSON Schema from list of dicts |
infer_type(value) |
Infer type for a single value |
merge_schemas(a, b) |
Merge two schemas |
Development
pip install -e .
python -m pytest tests/ -v
License
MIT
Project details
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 philiprehberger_schema_infer-0.1.6.tar.gz.
File metadata
- Download URL: philiprehberger_schema_infer-0.1.6.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de165126e540027db6ecfa0d46aa68feb3c5fcf680e2a78e5d0acd02fa2ec61a
|
|
| MD5 |
397ace76d332fb1e183d8ddf4cbc8dc9
|
|
| BLAKE2b-256 |
89b444a16d16ff1b7e8c9a24e982c9bef947f5380b95e751c67886ad3df9a8ea
|
File details
Details for the file philiprehberger_schema_infer-0.1.6-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_schema_infer-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d801089937b40476c433eedc3b449c0b1fc4e2d4bb01a4d9994e1aa76b9a13f8
|
|
| MD5 |
9af299dafabccfc936dc1978a4c84894
|
|
| BLAKE2b-256 |
01f749b51e5b769a2d2e4114fa20f268bef061f500f44bc0122c4eb27f9e8a9c
|