diff --git a/structs.go b/structs.go index 8a86283..8426a64 100644 --- a/structs.go +++ b/structs.go @@ -550,6 +550,11 @@ func (s *Struct) nested(val reflect.Value) interface{} { // TODO(arslan): should this be optional? finalVal = val.Interface() case reflect.Slice, reflect.Array: + if val.Type().Kind() == reflect.Interface { + finalVal = val.Interface() + break + } + // TODO(arslan): should this be optional? // do not iterate of non struct types, just pass the value. Ie: []int, // []string, co... We only iterate further if it's a struct. diff --git a/structs_test.go b/structs_test.go index 618d9f7..07c23db 100644 --- a/structs_test.go +++ b/structs_test.go @@ -1362,3 +1362,17 @@ func TestNonStringerTagWithStringOption(t *testing.T) { t.Errorf("Value for field Animal should not exist") } } + +func TestMap_InterfaceValue(t *testing.T) { + type TestStruct struct { + A interface{} + } + + expected := []byte("test value") + + a := TestStruct{A: expected} + s := Map(a) + if !reflect.DeepEqual(s["A"], expected) { + t.Errorf("Value does not match expected: %q != %q", s["A"], expected) + } +}