// Decode unmarshals incoming event to it's corresponding go type
Decode unmarshals incoming event to it's corresponding go type
// Decode unmarshals incoming event to it ' s corresponding go type
func (e *JsonEncoder) Decode(evt *EncodedEvt) (interface{}, error) {
	t, ok := e.types[evt.Type]
	if !ok {
		return nil, fmt.Errorf("event not registered via NewJSONEncoder")
	}
	v := reflect.New(t)
	err := json.Unmarshal([]byte(evt.Data), v.Interface())
	if err != nil {
		return nil, err
	}
	return v.Elem().Interface(), nil
}
func ( e * JsonEncoder ) Decode ( evt * EncodedEvt ) ( interface { } , error ) { t , ok := e . types [ evt . Type ] if ! ok { return nil , fmt . Errorf ( " " ) } v := reflect . New ( t ) err := json . Unmarshal ( [ ] byte ( evt . Data ) , v . Interface ( ) ) if err != nil { return nil , err } return v . Elem ( ) . Interface ( ) , nil }
Decode unmarshals incoming event to it's corresponding go type
Decode unmarshals incoming event to it ' s corresponding go type