Skip to main content

Add your description here

Project description

Jambo - JSON Schema to Pydantic Converter

Tests
Package version Python versions License

Jambo is a Python package that automatically converts JSON Schema definitions into Pydantic models. It's designed to streamline schema validation and enforce type safety using Pydantic's powerful validation features.

Created to simplifying the process of dynamically generating Pydantic models for AI frameworks like LangChain, CrewAI, and others.


✨ Features

  • ✅ Convert JSON Schema into Pydantic models dynamically
  • 🔒 Supports validation for strings, integers, floats, booleans, arrays, and nested objects
  • ⚙️ Enforces constraints like minLength, maxLength, pattern, minimum, maximum, uniqueItems, and more
  • 📦 Zero config — just pass your schema and get a model

📦 Installation

pip install jambo

🚀 Usage

from jambo.schema_converter import SchemaConverter

schema = {
    "title": "Person",
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"},
    },
    "required": ["name"],
}

Person = SchemaConverter.build(schema)

obj = Person(name="Alice", age=30)
print(obj)

✅ Example Validations

Strings with constraints

schema = {
    "title": "EmailExample",
    "type": "object",
    "properties": {
        "email": {
            "type": "string",
            "minLength": 5,
            "maxLength": 50,
            "pattern": r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$",
        },
    },
    "required": ["email"],
}

Model = SchemaConverter.build(schema)
obj = Model(email="user@example.com")
print(obj)

Integers with bounds

schema = {
    "title": "AgeExample",
    "type": "object",
    "properties": {
        "age": {"type": "integer", "minimum": 0, "maximum": 120}
    },
    "required": ["age"],
}

Model = SchemaConverter.build(schema)
obj = Model(age=25)
print(obj)

Nested Objects

schema = {
    "title": "NestedObjectExample",
    "type": "object",
    "properties": {
        "address": {
            "type": "object",
            "properties": {
                "street": {"type": "string"},
                "city": {"type": "string"},
            },
            "required": ["street", "city"],
        }
    },
    "required": ["address"],
}

Model = SchemaConverter.build(schema)
obj = Model(address={"street": "Main St", "city": "Gotham"})
print(obj)

🧪 Running Tests

To run the test suite:

poe tests

Or manually:

python -m unittest discover -s tests -v

🛠 Development Setup

To set up the project locally:

  1. Clone the repository
  2. Install uv (if not already installed)
  3. Install dependencies:
uv sync
  1. Set up git hooks:
poe create-hooks

📌 Roadmap / TODO

  • Support for enum and const
  • Support for anyOf, allOf, oneOf
  • Schema ref ($ref) resolution
  • Better error reporting for unsupported schema types

🤝 Contributing

PRs are welcome! This project uses MIT for licensing, so feel free to fork and modify as you see fit.


🧾 License

MIT License.

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

jambo-0.1.0.post2.tar.gz (42.7 kB view details)

Uploaded Source

File details

Details for the file jambo-0.1.0.post2.tar.gz.

File metadata

  • Download URL: jambo-0.1.0.post2.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for jambo-0.1.0.post2.tar.gz
Algorithm Hash digest
SHA256 487b31a01c826e17dd4efbd82acb4e6e5f0302b6b70f89ac2b005a3126b25168
MD5 0494bf51727f1c35ad96ee1b5d33ed63
BLAKE2b-256 0f2ab58a48a2c8d256b1fd13131267c870c4ca98685b94784e88550d6b98d94f

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