{"id":2314,"library":"toons","title":"toons: High-Performance TOON Parser and Serializer","description":"toons is a high-performance Python library for parsing and serializing TOON (Token Oriented Object Notation), implemented in Rust for speed. It offers an API that mirrors Python's built-in `json` module, making it easy to convert Python objects to TOON strings and vice-versa. TOON is a token-efficient data serialization format specifically designed to reduce token counts for Large Language Models. The current version is 0.5.4, with frequent minor releases addressing fixes and specification compliance.","status":"active","version":"0.5.4","language":"en","source_language":"en","source_url":"https://github.com/alesanfra/toons","tags":["parsing","serialization","data format","rust","performance","llm","token-efficiency"],"install":[{"cmd":"pip install toons","lang":"bash","label":"Install `toons`"}],"dependencies":[],"imports":[{"symbol":"loads","correct":"from toons import loads"},{"symbol":"dumps","correct":"from toons import dumps"}],"quickstart":{"code":"import toons\n\n# Sample Python data\ndata = {\n    \"name\": \"Alice\",\n    \"age\": 30,\n    \"tags\": [\"python\", \"rust\", \"toon\"]\n}\n\n# Serialize Python data to TOON string\ntoon_string = toons.dumps(data)\nprint(\"--- TOON String ---\")\nprint(toon_string)\n# Expected output (simplified, actual format may vary slightly based on spec):\n# name: Alice\n# age: 30\n# tags[3]: python,rust,toon\n\n# Parse TOON string back to Python data\nparsed_data = toons.loads(toon_string)\nprint(\"\\n--- Parsed Python Data ---\")\nprint(parsed_data)\n# Expected output:\n# {'name': 'Alice', 'age': 30, 'tags': ['python', 'rust', 'toon']}\n\n# Example with tabular data (common for LLMs)\nusers = [\n    {\"id\": 1, \"name\": \"Bob\", \"active\": True},\n    {\"id\": 2, \"name\": \"Charlie\", \"active\": False}\n]\ntabular_toon = toons.dumps(users)\nprint(\"\\n--- Tabular TOON String ---\")\nprint(tabular_toon)\n# Expected output (simplified):\n# [2]{id,name,active}:\n# 1,Bob,true\n# 2,Charlie,false","lang":"python","description":"This quickstart demonstrates how to serialize a Python dictionary and a list of dictionaries (tabular data) into TOON format, and then parse a TOON string back into a Python object using `toons.dumps` and `toons.loads`, mirroring the standard `json` library API."},"warnings":[{"fix":"Review the TOON Specification v3.0 for any changes relevant to your data structures and update your TOON inputs/outputs accordingly.","message":"Version 0.5.0 introduced compliance with TOON Specification v3.0, potentially causing breaking changes for users relying on data formatted under older TOON specifications (e.g., v2.0 from versions 0.3.x). Ensure your TOON data adheres to v3.0 when upgrading.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Upgrade to `toons` version 0.5.3 or later to ensure correct handling of unicode and datetime types.","message":"Older versions (prior to 0.5.3) had issues with deserialization of special unicode characters and (prior to 0.5.2) with serialization of datetime objects. If you're handling complex strings or datetimes, ensure you are on a recent version.","severity":"gotcha","affected_versions":"<0.5.3"},{"fix":"Ensure your TOON input strictly adheres to the v3.0 specification, or pass `strict=False` to `toons.loads()` for more tolerant parsing, e.g., `toons.loads(toon_str, options={'strict': False})`.","message":"By default, `toons` enforces strict compliance with the TOON v3.0 specification. Malformed TOON strings (e.g., those with incorrect indentation, invalid escape sequences, or blank lines in arrays) will raise errors during parsing. For lenient parsing, strict mode can be explicitly disabled.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}