[BUG] omitempty in decoder using ignoreunknowkeys option not working
Opened this issue · 0 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
type A struct{
F1 *int64 `schema:"f1"`
F2 string `schema:"f2"`
}
the decoder option is set as below
d := schema.NewDecoder()
d.IgnoreUnknownKeys(true)
if err := d.Decode(inp, v); err != nil {
return err
}
schema is decoded successfully but empty values are not omitted.
Expected Behavior
inp := new(A)
got result:
{"f1": 0 , "f2" : " "}
expected
{ }
docs - https://pkg.go.dev/github.com/gorilla/schema#Decoder.IgnoreUnknownKeys
this suggest is similar to encoding/json behaviour when a un known key is encountered it will be skipped and valid keys will still be decoded.
Am i doing something incorrect?
is there any other tag i need to add? like omitempty
Steps To Reproduce
No response
Anything else?
docs - https://pkg.go.dev/github.com/gorilla/schema#Decoder.IgnoreUnknownKeys
this suggest is similar to encoding/json behaviour when a un known key is encountered it will be skipped and valid keys will still be decoded.
Am i doing something incorrect?
is there any other tag i need to add? like omitempty