Metadata-Version: 2.4
Name: python-toon-parser
Version: 0.1.1
Summary: TOON (Token-Oriented Object Notation) serializer & parser for Python
Author-email: Akash Wankhede <akash.wankhede.pune@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/akash1551/pytoon
Project-URL: Source, https://github.com/akash1551/pytoon
Project-URL: Issues, https://github.com/akash1551/pytoon/issues
Keywords: toon,serialization,parser,format,llm,data
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Software Development :: Libraries
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# python-toon-parser

![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
![Version](https://img.shields.io/badge/pypi-v0.1.0-blue)
![License](https://img.shields.io/badge/license-MIT-green)

`python-toon-parser` — **TOON** (**T**oken-**O**riented **O**bject **N**otation) serializer and parser for Python.

## Installation

```bash
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

```python
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:**
```yaml
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.
