Support interface{} types in the struct
diff --git a/mapstructure.go b/mapstructure.go
index 9da5586..11bde03 100644
--- a/mapstructure.go
+++ b/mapstructure.go
@@ -65,6 +65,8 @@
switch k {
case reflect.Bool:
fallthrough
+ case reflect.Interface:
+ fallthrough
case reflect.String:
return decodeBasic(name, data, val)
case reflect.Int:
diff --git a/mapstructure_test.go b/mapstructure_test.go
index c74fea6..453fc56 100644
--- a/mapstructure_test.go
+++ b/mapstructure_test.go
@@ -8,6 +8,7 @@
Vbool bool
Vextra string
vsilent bool
+ Vdata interface{}
}
type Map struct {
@@ -45,6 +46,7 @@
"vint": 42,
"vbool": true,
"vsilent": true,
+ "vdata": 42,
}
var result Basic
@@ -73,6 +75,10 @@
if result.vsilent != false {
t.Error("vsilent should not be set, it is unexported")
}
+
+ if result.Vdata != 42 {
+ t.Error("vdata should be valid")
+ }
}
func TestBasic_IntWithFloat(t *testing.T) {