python-toon-parser — TOON (Token-Oriented Object Notation) serializer and parser for Python.
pip install python-toon-parser- Human-Readable: Minimal syntax, similar to YAML but distinct.
- Round-Trip:
dumps(obj)->loads(text)preserves structure. - Compact Tables: Automatically detects lists of uniform objects and formats them as compact tables.
- Broad Support: Handles
dict,list,tuple,set,dataclasses,namedtuples, and simple objects.
from pytoon import dumps, loads
data = {"items": [{"id":1,"name":"A"}, {"id":2,"name":"B"}]}
# Serialize
s = dumps(data)
print(s)
# Parse back
obj = loads(s)
print(obj)Output:
items[2]{id,name}:
1,A
2,BSerializes a Python object to a TOON string.
obj: The object to serialize.name: (Optional) Root key name for the object.indent: (Optional) Starting indentation level (default 0).
Parses a TOON string back into Python objects.
- Returns
dict,list, or primitive depending on the input.