{"id":33025673,"url":"https://github.com/jassielof/ztoon","last_synced_at":"2025-11-13T20:00:50.688Z","repository":{"id":323537282,"uuid":"1090754852","full_name":"jassielof/ztoon","owner":"jassielof","description":"A Zig implementation of the TOON (Token-Oriented Object Notation) format.","archived":false,"fork":false,"pushed_at":"2025-11-10T18:16:12.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-10T19:13:21.579Z","etag":null,"topics":["ai","toon","toon-format","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jassielof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-06T05:05:06.000Z","updated_at":"2025-11-10T18:16:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jassielof/ztoon","commit_stats":null,"previous_names":["jassielof/ztoon"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jassielof/ztoon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jassielof%2Fztoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jassielof%2Fztoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jassielof%2Fztoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jassielof%2Fztoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jassielof","download_url":"https://codeload.github.com/jassielof/ztoon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jassielof%2Fztoon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284282007,"owners_count":26978297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-13T02:00:06.582Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","toon","toon-format","zig"],"created_at":"2025-11-13T20:00:32.609Z","updated_at":"2025-11-13T20:00:50.683Z","avatar_url":"https://github.com/jassielof.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Z-TOON: Zig TOON\n\nA Zig implementation of the TOON (Token-Oriented Object Notation) format, version 2.0.\n\n## What is TOON?\n\nTOON is a line-oriented, indentation-based text format that encodes the JSON data model with explicit structure and minimal quoting. It's particularly efficient for arrays of uniform objects, providing a more compact and readable alternative to JSON for structured data.\n\nSee the [full specification](https://github.com/toon-format/spec) for details in depth.\n\n## Features\n\n- [x] **Core Encoding/Decoding**: Full JSON ↔ TOON conversion\n- [x] **Primitives**: strings, numbers, booleans, null with smart quoting\n- [x] **Objects**: Nested objects with indentation-based structure\n- [x] **Arrays**: Both inline (primitives) and multi-line (objects/nested)\n- [x] **Tabular Arrays**: Compact `[N]{field1,field2}:` format for uniform object arrays\n- [x] **Alternative Delimiters**: Comma (default), tab (`\\t`), and pipe (`|`) support\n- [x] **Delimiter Detection**: Automatic delimiter detection in array headers `[N\u003cdelim\u003e]`\n- [x] **CLI Tool**: Encode and decode via command line or pipes\n\n## Building\n\nRequires Zig 0.15.2 or later:\n\n```\nzig build\n```\n\nThe binary will be available at `./zig-out/bin/ztoon`.\n\n## Usage\n\n### CLI\n\n**Encode JSON to TOON:**\n```bash\necho '{\"name\": \"Alice\", \"age\": 30}' | ./zig-out/bin/ztoon encode\n```\n\nOutput:\n```\nname: Alice\nage: 30\n```\n\n**Decode TOON to JSON:**\n```bash\necho 'name: Alice\nage: 30' | ./zig-out/bin/ztoon decode\n```\n\nOutput:\n```json\n{\n  \"name\": \"Alice\",\n  \"age\": 30\n}\n```\n\n**From files:**\n```bash\n./zig-out/bin/ztoon encode input.json\n./zig-out/bin/ztoon decode input.toon\n```\n\n### Library\n\n```zig\nconst std = @import(\"std\");\nconst toon = @import(\"ztoon\");\n\npub fn main() !void {\n    var gpa = std.heap.GeneralPurposeAllocator(.{}){};\n    defer _ = gpa.deinit();\n    const allocator = gpa.allocator();\n\n    // Create a value\n    var obj = std.StringHashMap(toon.Value).init(allocator);\n    defer obj.deinit();\n\n    try obj.put(\"name\", toon.Value{ .string = \"Alice\" });\n    try obj.put(\"age\", toon.Value{ .number = 30 });\n\n    const value = toon.Value{ .object = obj };\n    defer value.deinit(allocator);\n\n    // Encode to TOON\n    const encoded = try toon.encode(allocator, value, .{});\n    defer allocator.free(encoded);\n\n    std.debug.print(\"TOON: {s}\\n\", .{encoded});\n\n    // Decode from TOON\n    var decoded = try toon.decode(allocator, encoded, .{});\n    defer decoded.deinit(allocator);\n}\n```\n\n## Examples\n\n### Simple Object\n```json\n{\"name\": \"Alice\", \"age\": 30, \"active\": true}\n```\n↓\n```toon\nname: Alice\nage: 30\nactive: true\n```\n\n### Nested Objects\n```json\n{\"user\": {\"name\": \"Alice\", \"settings\": {\"theme\": \"dark\"}}}\n```\n↓\n```toon\nuser:\n  name: Alice\n  settings:\n    theme: dark\n```\n\n### Tabular Array (Uniform Objects)\n```json\n{\"items\": [\n  {\"sku\": \"A1\", \"qty\": 2, \"price\": 9.99},\n  {\"sku\": \"B2\", \"qty\": 1, \"price\": 14.5}\n]}\n```\n↓\n```toon\nitems:[2]{sku,price,qty}:\n  A1,9.99,2\n  B2,14.5,1\n```\n\n### Pipe-Delimited Tabular Array\n```json\n{\"users\": [\n  {\"name\": \"Alice\", \"role\": \"admin\"},\n  {\"name\": \"Bob\", \"role\": \"dev\"}\n]}\n```\n↓\n```toon\nusers:[2|]{name|role}:\n  Alice|admin\n  Bob|dev\n```\n\n### Primitive Array\n```json\n{\"items\": [1, 2, 3, 4, 5]}\n```\n↓\n```toon\nitems[5]: 1,2,3,4,5\n```\n\n### Array of Objects (Non-Uniform)\n```json\n{\"users\": [{\"name\": \"Alice\", \"id\": 1}, {\"name\": \"Bob\", \"id\": 2}]}\n```\n↓\n```toon\nusers[2]:\n  -\n    name: Alice\n    id: 1\n  -\n    name: Bob\n    id: 2\n```\n\n## Status \u0026 Roadmap\n\n### Implemented ✅\n- Core TOON encoder and decoder\n- Nested objects with indentation\n- Tabular arrays with field lists\n- Alternative delimiters (comma, tab, pipe)\n- Delimiter detection from array headers\n- Smart string quoting\n- CLI tool\n- Field order preservation (deterministic output)\n- Comprehensive error messages with line/column information\n\n### Planned 📋\n- Key folding (`keyFolding=\"safe\"` mode) - collapse single-key object chains into dotted notation\n- Path expansion (`expandPaths=\"safe\"` mode) - split dotted keys into nested objects\n- Strict mode validation (length mismatches, malformed headers)\n- Conformance test suite from `spec/tests/fixtures/`\n- Performance optimizations\n- Benchmarks vs JSON\n\n### Known Limitations ⚠️\n- Some edge cases from spec may not be fully covered\n- Non-strict mode has limited validation\n\n## Next Steps\n\nTo continue improving this implementation:\n\n1. **Conformance Tests**: Load and run test fixtures from `spec/tests/fixtures/` for full spec compliance\n2. **Strict Mode**: Implement validation for length mismatches, invalid characters, and malformed headers\n3. **Key Folding**: Implement optional `keyFolding=\"safe\"` mode for dotted-path notation\n4. **Path Expansion**: Implement optional `expandPaths=\"safe\"` mode for splitting dotted keys\n5. **Better Delimiters**: Auto-select optimal delimiter on encode based on content analysis\n6. **Performance**: Profile and optimize hot paths, especially for large tabular arrays\n7. **Documentation**: Add inline documentation and more usage examples\n\n## Testing\n\nCurrently tested manually with various inputs. Run some quick tests:\n\n```bash\n# Test nested objects\necho '{\"a\":1,\"b\":{\"c\":2}}' | ./zig-out/bin/ztoon encode | ./zig-out/bin/ztoon decode\n\n# Test tabular arrays\necho '{\"items\":[{\"id\":1,\"name\":\"Alice\"},{\"id\":2,\"name\":\"Bob\"}]}' | ./zig-out/bin/ztoon encode\n\n# Test with different delimiters\nprintf 'items:[2|]{name|role}:\\n  Alice|admin\\n  Bob|dev' | ./zig-out/bin/ztoon decode\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjassielof%2Fztoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjassielof%2Fztoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjassielof%2Fztoon/lists"}