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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2b9dc6475e2c895e47bd568a0adaa2b95d5d57ca02a547fe85b673ecebc01f80
MD5 14b4c9236a1f7ccdbc24743077f16763
BLAKE2b-256 33cf53b98a1a591e2417ba3d6a595ed69366e71bfe3c50d7bfd21857f29b92e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_schema_infer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a2cef0fe6fa024829cba1336dc023f935a6d5b041ab652563131aab1549622e
MD5 e9d888687738ed07cc149d774c126f9f
BLAKE2b-256 ab802c33027dcd200f9170c8c1f03ff08d9fd2dec893cb3151abd0635dfbedcf

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