Skip to main content

Infer JSON schemas from sample data

Project description

philiprehberger-schema-infer

Tests PyPI version License

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

  • 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

License

MIT

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

philiprehberger_schema_infer-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_schema_infer-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_schema_infer-0.1.2.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 98300fed507ddfe430d5a76fed926271581b52635be540fd3298e6e0addec468
MD5 0892bdfe07486d3c9180c0a4f06ecc94
BLAKE2b-256 a53f67a0eddcbc36a03de61674f26592b31b56f04006b6a854e33cd1049d6e71

See more details on using hashes here.

File details

Details for the file philiprehberger_schema_infer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22a24654e8717b32a360aef9e2264d1919cd0623647bb1e56daa823f07e8353a
MD5 1881a85d46cbc7ff75038989e15218c4
BLAKE2b-256 c1922d0a194c60e41435bf784e8e60b94686f2f17248f26052c29d91c1db8076

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page