Skip to main content

Wrapper around `jsonish` from BAML

Project description

jsonish_py

A Python wrapper around BAML's jsonish crate for flexible JSON-like parsing.

Overview

This library uses BAML's Rust-based jsonish parser to handle malformed or non-standard JSON strings that regular parsers would reject. It provides two main functions:

  • parse_to_json - Parses JSON-like strings into standard JSON
  • parse_to_model - A utility that combines parsing with Pydantic model validation

Installation

pip install jsonish_py

Usage

Basic JSON parsing

import jsonish_py

# Standard JSON works fine
result = jsonish_py.parse_to_json('{"name": "John", "age": 30}')
# Returns: '{"name": "John", "age": 30}'

# But it also handles malformed JSON
result = jsonish_py.parse_to_json('{"name": John, "age": 30,}')  # Missing quotes, trailing comma
result = jsonish_py.parse_to_json("{'name': 'John'}")  # Single quotes

Parsing to Pydantic models

from pydantic import BaseModel
import jsonish_py

class User(BaseModel):
    name: str
    age: int

# Parse directly to a Pydantic model
user = jsonish_py.parse_to_model('{"name": "Alice", "age": 25}', User)
print(user.name)  # Alice
print(user.age)   # 25

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

jsonish_py-0.0.1.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonish_py-0.0.1-cp313-cp313-macosx_11_0_arm64.whl (922.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file jsonish_py-0.0.1.tar.gz.

File metadata

  • Download URL: jsonish_py-0.0.1.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for jsonish_py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3aaa556b764374a30260c5930d1b40d1f6ecd215a4e2a516a90a02fede330bfb
MD5 9cb0f1d2b8f678f0eb594e0d023815d0
BLAKE2b-256 624c2df69356a039a6f1de9292f8a082fc5ac5bceb43935ccb9f3f4a9ef5a639

See more details on using hashes here.

File details

Details for the file jsonish_py-0.0.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for jsonish_py-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e99c24583a24196d532b6851b5ee13c7231f1c77110d0e6b1d64874ad589de5a
MD5 4e22faa4ce1d0be95c43387050091004
BLAKE2b-256 39303e7db4397bf15277f4b40c7032107213c461cc6aee14eefd7bc890d495d0

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