Skip to main content

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

  • 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.0.tar.gz (4.6 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.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57ccebe9cd1eef7981e33cd114dc47233001ec4ebe05daa323b538efa2f7c20b
MD5 e9570a53f3189067fb3f1ec7826c9c6b
BLAKE2b-256 82fd1bbcc7086be3e4e0a7b76b9ea38f13f4db8a2fa0674577e44b7be575f048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edcf96036d12b8efa0c50f62fae04d45fd437166cb5c299398425f1703c46385
MD5 103ebd8f5baf5795980ab41c2b2b3409
BLAKE2b-256 30e5bce9311d52694294593153104c499977dac0daecaf03f0ca75db820417af

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