Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterTypeEncoderFunc isEmptyFunc never called #661

Open
kimmykong opened this issue Feb 28, 2023 · 0 comments
Open

RegisterTypeEncoderFunc isEmptyFunc never called #661

kimmykong opened this issue Feb 28, 2023 · 0 comments

Comments

@kimmykong
Copy link

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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant