High-performance Go support for ASON, a schema-driven format for compact structured data.
ASON writes field names once and stores rows positionally:
[
{"id": 1, "name": "Alice", "active": true},
{"id": 2, "name": "Bob", "active": false}
][{id:int,name:str,active:bool}]:(1,Alice,true),(2,Bob,false)
That reduces repeated keys, payload size, and often parsing cost.
- Standard library only
- Current API uses
Encode/Decode, not the olderMarshal/Unmarshalnames - Text, pretty text, and binary formats
- Struct tags via
ason:"...", withjsontag fallback - Good fit for LLM payloads, internal services, logs, and fixtures
go get github.com/ason-lab/ason-gopackage main
import (
"fmt"
ason "github.com/ason-lab/ason-go"
)
type User struct {
ID int64 `ason:"id"`
Name string `ason:"name"`
Active bool `ason:"active"`
}
func main() {
user := User{ID: 1, Name: "Alice", Active: true}
text, _ := ason.Encode(&user)
fmt.Println(string(text))
// {id,name,active}:(1,Alice,true)
typed, _ := ason.EncodeTyped(&user)
fmt.Println(string(typed))
// {id:int,name:str,active:bool}:(1,Alice,true)
var decoded User
_ = ason.Decode(text, &decoded)
}users := []User{
{ID: 1, Name: "Alice", Active: true},
{ID: 2, Name: "Bob", Active: false},
}
text, _ := ason.Encode(users)
typed, _ := ason.EncodeTyped(users)
var decoded []User
_ = ason.Decode(text, &decoded)pretty, _ := ason.EncodePretty(users)
prettyTyped, _ := ason.EncodePrettyTyped(users)
bin, _ := ason.EncodeBinary(users)
var decoded []User
_ = ason.DecodeBinary(bin, &decoded)| Function | Purpose |
|---|---|
Encode / EncodeTyped |
Encode to text |
Decode |
Decode from text |
EncodePretty / EncodePrettyTyped |
Pretty text output |
EncodeBinary |
Encode to binary |
DecodeBinary |
Decode from binary |
go test ./...
go run ./examples/basic
go run ./examples/complex
go run ./examples/benchMeasured on this machine with:
go run ./examples/benchHeadline numbers:
- Flat 1,000-record dataset: ASON serialize
15.71msvs JSON76.92ms, deserialize77.32msvs JSON380.56ms - Flat 10,000-record dataset: ASON serialize
75.82msvs JSON173.69ms, deserialize283.21msvs JSON770.39ms - Deep 100-record dataset: ASON serialize
425.39msvs JSON699.25ms, deserialize1136.91msvs JSON3001.79ms - Throughput summary on 1,000 records: ASON text was
3.37xfaster than JSON for serialize and4.40xfaster for deserialize - Binary summary on 1,000 flat records: BIN serialize
22.8msvs JSON32.1ms, BIN deserialize15.2msvs JSON186.2ms, with binary size74,450 B
MIT