Skip to content

Update PyPi #19

@zhiweit

Description

@zhiweit

Hi, thanks for implementing this in python. Can you update the package on PyPi?

The encode function is not implemented on Pypi.

E.g.

uv add toon_format

this is the current toon encoder implementation from the pypi package pulled

"""TOON encoder implementation."""

from typing import Any

from toon_format.types import EncodeOptions


def encode(value: Any, options: EncodeOptions | None = None) -> str:
    """Convert a value to TOON format.

    Args:
        value: Any JSON-serializable value (object, array, primitive, or nested structure).
               Non-JSON-serializable values (functions, undefined, non-finite numbers) are
               converted to null. Dates are converted to ISO strings, and BigInts are emitted
               as decimal integers.
        options: Optional encoding options:
            - indent: Number of spaces per indentation level (default: 2)
            - delimiter: Delimiter for array values and tabular rows (default: ',')
            - length_marker: Optional marker to prefix array lengths (default: False)

    Returns:
        A TOON-formatted string with no trailing newline or spaces.

    Examples:
        >>> encode({"items": [{"sku": "A1", "qty": 2}, {"sku": "B2", "qty": 1}]})
        'items[2]{sku,qty}:\\n  A1,2\\n  B2,1'

        >>> encode({"tags": ["foo", "bar"]}, {"delimiter": "\\t"})
        'tags[2    ]: foo    bar'

        >>> encode([1, 2, 3], {"length_marker": "#"})
        '[#3]: 1,2,3'
    """
    raise NotImplementedError("TOON encoder is not yet implemented")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions