A Go implementation of ZOON (Zero Overhead Object Notation) - the most token-efficient data format for LLMs.
go get github.com/zoon-format/zoon-gopackage main
import (
"fmt"
zoon "github.com/zoon-format/zoon-go"
)
type User struct {
ID int `zoon:"id"`
Name string `zoon:"name"`
Role string `zoon:"role"`
Active bool `zoon:"active"`
}
func main() {
users := []User{
{1, "Alice", "Admin", true},
{2, "Bob", "User", false},
}
encoded, _ := zoon.Marshal(users)
fmt.Println(string(encoded))
// Output:
// # id:i+ name:s role=Admin|User active:b
// Alice Admin 1
// Bob User 0
}data := `# id:i+ name:s role=Admin|User active:b
Alice Admin 1
Bob User 0`
var users []User
zoon.Unmarshal([]byte(data), &users)
fmt.Printf("%+v\n", users)
// [{ID:1 Name:Alice Role:Admin Active:true} {ID:2 Name:Bob Role:User Active:false}]type Config struct {
Host string `zoon:"host"`
Port int `zoon:"port"`
SSL bool `zoon:"ssl"`
}
cfg := Config{"localhost", 3000, true}
encoded, _ := zoon.Marshal(cfg)
// host=localhost port:3000 ssl:y| Function | Description |
|---|---|
Marshal(v any) ([]byte, error) |
Encode any value to ZOON |
Unmarshal(data []byte, v any) error |
Decode ZOON into a value |
NewEncoder(w io.Writer) *Encoder |
Create streaming encoder |
NewDecoder(r io.Reader) *Decoder |
Create streaming decoder |
| Go Type | ZOON Type | Header |
|---|---|---|
int |
Integer | :i |
bool |
Boolean | :b |
string |
String | :s |
*T (nil) |
Null | ~ |
| Auto-increment ID | Implicit | :i+ |
MIT License - Copyright (c) 2025-PRESENT Carsen Klock