amazon-ion / ion-go

A Go implementation of Amazon Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
174 stars 31 forks source link

Add annotations when Marshalling values #104

Closed R-maan closed 4 years ago

R-maan commented 4 years ago

Encoder does not take annotations and consequently Marshal cannot serialize values with annotations.

To get the annotations when Marshalling, user should send a struct to Marshal() whereby one field of the struct is a slice of string and tagged as ion:",annotations".

For instance:

type foo struct {
   Value   int
   AnyName []string `ion:",annotations"`
}
...
val := foo{5, []string{"age"}}
buf := MarshalText(val)