You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
Hello,
When decoding a struct to a map custom DecodeHooks are not called for non struct fields.
This originates from line 975 in mapstructure.go where fields valued are just copied to the map.
In my eyes it would make sense to also call hooks when decoding a struct field to a map as well so it is possible to overwrite what is written to the map.
E.g. I've got the following model definition inside my application:
ObjectID is a custom type from mongo-go-driver. It is an array of length 12. Its zero value is also an array of 12. because of that omitempty flag does not work. However my custom decoder could take care of this and decide to decode the ObjectID to nil if it corresponds to its zero value.
Input type and output type given to the hook could be the same.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
When decoding a struct to a map custom DecodeHooks are not called for non struct fields.
This originates from line 975 in mapstructure.go where fields valued are just copied to the map.
In my eyes it would make sense to also call hooks when decoding a struct field to a map as well so it is possible to overwrite what is written to the map.
E.g. I've got the following model definition inside my application:
ObjectID is a custom type from mongo-go-driver. It is an array of length 12. Its zero value is also an array of 12. because of that omitempty flag does not work. However my custom decoder could take care of this and decide to decode the ObjectID to nil if it corresponds to its zero value.
Input type and output type given to the hook could be the same.
The text was updated successfully, but these errors were encountered: