package borealis import ( "encoding/json" ) type Event struct { Type uint16 TimestampS uint32 TimestampMS uint16 SequentialID uint64 UniqueID []byte Payload interface{} } func (event Event) MarshalJSON() ([]byte, error) { array := []interface{}{ event.Type, event.TimestampS, event.TimestampMS, event.SequentialID, event.UniqueID, event.Payload, } 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)) event.TimestampS = uint32(array[1].(float64)) event.TimestampMS = uint16(array[2].(float64)) event.SequentialID = uint64(array[3].(float64)) event.UniqueID = array[4].([]byte) event.Payload = array[5] return nil }