Skip to content

Conversation

Copy link

Copilot AI commented Nov 30, 2025

Port of the TypeScript ZON (Zero Overhead Notation) package to Go. ZON is a token-efficient serialization format for LLM workflows achieving 23-50% token reduction vs JSON through tabular encoding and single-character primitives.

Core Library

  • Encoder (encoder.go): Automatic tabular format detection, T/F booleans, canonical numbers (no scientific notation), NaN/Infinity→null
  • Decoder (decoder.go): Strict mode validation, security limits, dotted key unflattening, prototype pollution prevention
  • Error handling (errors.go): Documented error codes E001-E003 (validation), E301-E305 (security limits)
  • Constants (constants.go): Security limits (100MB docs, 1MB lines, 1M arrays, 100K keys, 100 nesting depth)

CLI Tool

zon encode data.json > data.zonf
zon decode data.zonf > output.json

Usage

import zon "github.com/ZON-Format/zon-go"

data := map[string]any{
    "users": []any{
        map[string]any{"id": 1, "name": "Alice", "active": true},
        map[string]any{"id": 2, "name": "Bob", "active": false},
    },
}

encoded, _ := zon.Encode(data)
// users:@(2):active,id,name
// T,1,Alice
// F,2,Bob

decoded, _ := zon.Decode(encoded)

Tests

94 tests covering:

  • Round-trip codec, canonical numbers, conformance (encoder/decoder)
  • Security limits, strict mode validation, prototype pollution

Documentation

  • README, SPEC.md, docs/ (syntax cheatsheet, API reference, LLM best practices)
  • Benchmark reports copied from zon-ts

License

MIT with author: Roni Bhakta

Original prompt

https://github.com/ZON-Format/zon-ts
Based on this package, I’ve provided you with the logic and motivation of the encoder, decoder, and CLI. Please produce the same tests for the go package. Additionally, ensure it’s MIT-licensed with my name, which is mentioned in the provided repo
Make sure that the accuracy is the same as per the go language. Also, produce all the documentation as per the guidelines provided. You can copy the benchmark reports from the above package into the go package


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 30, 2025 14:53
Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
…ed headers

Co-authored-by: ronibhakta1 <77425964+ronibhakta1@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests and documentation for Go package Implement ZON encoder/decoder with comprehensive tests and documentation Nov 30, 2025
Copilot AI requested a review from ronibhakta1 November 30, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants