A lightweight library to convert between TOON (Token-Oriented Object Notation) and popular data formats (JSON, YAML, XML, CSV).
Project description
🚀 TOON Converter (Python)
A lightweight library to convert between TOON (Token-Oriented Object Notation) and popular data formats (JSON, YAML, XML, CSV).
Reduce your LLM token costs by up to 40% using the TOON format!
📦 Installation
pip install toon-parse
🚀 Quick Start
from toon_parse import ToonConverter
# JSON to TOON
data = {"name": "Alice", "age": 30, "active": True}
toon_string = ToonConverter.from_json(data)
print(toon_string)
# Output:
# name: "Alice"
# age: 30
# active: true
# TOON to JSON
json_output = ToonConverter.to_json(toon_string)
print(json_output)
⚡ Async Usage
For non-blocking operations in async applications, use AsyncToonConverter:
import asyncio
from toon_parse import AsyncToonConverter
async def main():
data = {"name": "Alice", "age": 30}
# Async conversion
toon_string = await AsyncToonConverter.from_json(data)
print(toon_string)
# Async parsing
json_output = await AsyncToonConverter.to_json(toon_string)
print(json_output)
asyncio.run(main())
📚 API Reference
The Python API mirrors the JavaScript API with snake_case naming conventions.
ToonConverter.from_json(data)ToonConverter.to_json(toon_string)ToonConverter.from_yaml(yaml_string)ToonConverter.to_yaml(toon_string)ToonConverter.from_xml(xml_string)ToonConverter.to_xml(toon_string)ToonConverter.from_csv(csv_string)ToonConverter.to_csv(toon_string)ToonConverter.validate(toon_string)AsyncToonConverter.*(same methods as above, but async)
📄 License
MIT License
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
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 toon_parse-1.0.3.tar.gz.
File metadata
- Download URL: toon_parse-1.0.3.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1ca00e6076f074a182c0da628a5683f20e3df68e847df319c07eaf8ebf53d31
|
|
| MD5 |
320295ab6d5724641e47c812278d79bf
|
|
| BLAKE2b-256 |
657fb21d45aecdb3822a979e5f79d2257d8211c0793694776c1b6955afed3a34
|
File details
Details for the file toon_parse-1.0.3-py3-none-any.whl.
File metadata
- Download URL: toon_parse-1.0.3-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23018beec508ea65dc0512707249b36e8b6e6d59225f208fd8e85dbf73535822
|
|
| MD5 |
72f23f0c853b76d17af61ce3a14a1796
|
|
| BLAKE2b-256 |
c510cddd499259e38103a5a51ab91c06fef5a430ddbe52631639bd45fcc4e969
|