Open
Description
Json fields with hypen (-) are not decoded properly (BTW same for original mitchellh/mapstructure).
Minimal reproduction code (tried with go 1.22.5, 1.24)
package main
import (
"fmt"
"github.com/go-viper/mapstructure/v2"
)
type Out struct {
Foo int `json:"foo"`
BarBaz int `json:"bar-baz"`
}
func main() {
in := make(map[string]any)
in["foo"] = 1
in["bar-baz"] = 2
out := new(Out)
mapstructure.Decode(in, out)
fmt.Printf("%+v", out)
}
Actual
&{Foo:1 BarBaz:0}
Expected
&{Foo:1 BarBaz:2}
Metadata
Metadata
Assignees
Labels
No labels