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 JSONparse_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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aaa556b764374a30260c5930d1b40d1f6ecd215a4e2a516a90a02fede330bfb
|
|
| MD5 |
9cb0f1d2b8f678f0eb594e0d023815d0
|
|
| BLAKE2b-256 |
624c2df69356a039a6f1de9292f8a082fc5ac5bceb43935ccb9f3f4a9ef5a639
|
File details
Details for the file jsonish_py-0.0.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: jsonish_py-0.0.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 922.5 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e99c24583a24196d532b6851b5ee13c7231f1c77110d0e6b1d64874ad589de5a
|
|
| MD5 |
4e22faa4ce1d0be95c43387050091004
|
|
| BLAKE2b-256 |
39303e7db4397bf15277f4b40c7032107213c461cc6aee14eefd7bc890d495d0
|