GetSchema

0.2.11 · active · verified Sun Apr 12

GetSchema is a Python library designed to infer JSON schemas from sample data records. It analyzes diverse data inputs to automatically generate a robust JSON Schema definition. The project is actively maintained, with frequent patch releases addressing bug fixes and minor feature enhancements, currently at version 0.2.11.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `getschema.infer_schema` to generate a JSON Schema from a list of Python dictionaries representing sample records. The output is a formatted JSON string of the inferred schema.

import getschema
import json

sample_records = [
    {"name": "Alice", "age": 30, "city": "New York"},
    {"name": "Bob", "age": 24, "city": "London", "email": "bob@example.com"},
    {"name": "Charlie", "age": None, "city": "Paris"},
    {"name": "David", "age": 35, "city": "Berlin", "hobbies": ["reading", "hiking"]}
]

# Infer schema from a list of records
schema = getschema.infer_schema(sample_records)
print(json.dumps(schema, indent=2))

view raw JSON →