-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
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_formatthis 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")d8rt8v, fvisticot, yuriishizawa, Biskwit, ZipZapZeps and 5 more
Metadata
Metadata
Assignees
Labels
No labels