RegisterTypeEncoderFunc isEmptyFunc never called
kimmykong opened this issue · 0 comments
kimmykong commented
When I pass an isEmptyFunc function to RegisterTypeEncoderFunc, my isEmptyFunc is never called. My EncoderFunc for the type does get called. Request is for the isEmptyFunc to be called.
My data looks like this, where TypeC is an array that can have empty bytes saved. When I use jsoniter.RegisterFieldEncoderFunc(reflect2.TypeOf(TypeB{}).String(), "TypeC", encodeB, isBEmpty), both encodeB and isBEmpty functions get called, but I lose the support for array type and can't parse out the empty []byte
type TypeA struct {
TypeB TypeB
}
type TypeB struct {
TypeC []TypeC `msgpack:"as_array" json:"omitempty"`
}
type TypeC []byte
func fun() {
jsoniter.RegisterTypeEncoderFunc(reflect2.TypeOf(TypeC{}).String(), encodeFunc, isEmptyFunc)
}