package borealis import ( "encoding/json" ) type Event struct { Type uint16 } func (event Event) MarshalJSON() ([]byte, error) { array := []interface{}{event.Type} return json.Marshal(array) } func (event *Event) UnmarshalJSON(input []byte) error { array := []interface{}{} if err := json.Unmarshal(input, &array); err != nil { return err } event.Type = uint16(array[0].(float64)) return nil }