Version int `json:"version"` Event json.RawMessage `json:"data"` } func (e *Event) UnmarshalJSON(b []byte) error { var r raw _ = json.Unmarshal(b, &r) switch r.Version { case 1: return e.unmarshalJSONV1(r.Event) case 2: return e.unmarshalJSONV2(r.Event) } } 8