Skip to main content

TOON (Token-Oriented Object Notation) serializer & parser for Python

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_toon_parser-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_toon_parser-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file python_toon_parser-0.1.1.tar.gz.

File metadata

  • Download URL: python_toon_parser-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for python_toon_parser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b7225b6d39354759b34ede6181696d3a72a905bbcf73315eaf7e1054fd62e7a0
MD5 2137ac56a02de8efb5f0996a7e00d554
BLAKE2b-256 1cf379f69e4c9602d3e4c5a7d89ba80a55423f751c7685df07fd7b523dc35a94

See more details on using hashes here.

File details

Details for the file python_toon_parser-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_toon_parser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40ceed7e0dc76d25881e3bf4dc2d910ad146082195c9222e4d0fe1b705dcecd6
MD5 d25368b90b3bc33852a1d85cb93d0946
BLAKE2b-256 6857f2dda4db3165b0e1da9cec77b6af276a1bd06f4a9433dca65d2acacb9be0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page