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.1.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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8d731f1c5976969655c4e9762a15041d1d99600de82fec4cdac9b36c734635cc
MD5 1ea53e11b8abfc84f68d9a83cc48a284
BLAKE2b-256 08145223474d6f7f51871b760ac6866d7c53ac8cbcf190a48f10e25b60fbba2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0445ed4256cbb4e4ddc5ad282d21e432e542d7499c8cafb62247bcb9ea678498
MD5 1f2b9dd1ac16970aa5e27fe397cfd809
BLAKE2b-256 aa645742469376685503b34bf5023db73cdbd9dccd66a2b96299010659a75ec4

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