Skip to content

akash1551/pytoon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-toon-parser

Build Status Version License

python-toon-parserTOON (Token-Oriented Object Notation) serializer and parser for Python.

Installation

pip install python-toon-parser

Features

  • 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.

Quickstart

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,B

API Reference

dumps(obj, name=None, indent=0) -> str

Serializes 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).

loads(toon_str) -> Any

Parses a TOON string back into Python objects.

  • Returns dict, list, or primitive depending on the input.

About

`pytoon` — TOON (Token-Oriented Object Notation) serializer and parser for Python.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages