Skip to content

Commit

Permalink
Fix unmarshalling struct with custom json tag claim
Browse files Browse the repository at this point in the history
  • Loading branch information
o1egl committed Apr 25, 2020
1 parent 335bd84 commit f1000e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions json_token.go
Expand Up @@ -110,6 +110,7 @@ func (t *JSONToken) Get(key string, v interface{}) error {
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
DecodeHook: decodeHook,
Result: v,
TagName: "json",
})
if err != nil {
return errors.Errorf("failed to create map decoder: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion json_token_test.go
Expand Up @@ -41,7 +41,7 @@ func TestJsonToken(t *testing.T) {
type CustomStruct struct {
Foo string
Bar int
StrInt StrInt
StrInt StrInt `json:"custom_field"`
}

var (
Expand Down

0 comments on commit f1000e3

Please sign in to comment.