Add support for nested interface{} unmarshal (#335)

Co-authored-by: jlwang <jlwang@sysnew.com>

Fixes #331
This commit is contained in:
jinleiw
2020-03-16 22:38:53 +08:00
committed by GitHub
parent 3503483c73
commit ad60b7e437
2 changed files with 48 additions and 0 deletions
+10
View File
@@ -692,6 +692,16 @@ func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}, mval1 *ref
if isTree(mtype) {
return d.valueFromTree(mtype, t, mval11)
}
if mtype.Kind() == reflect.Interface &&
mval1.Elem().Kind() == reflect.Ptr &&
reflect.TypeOf(mval1.Elem()).Kind() == reflect.Struct {
mval111 := reflect.ValueOf(mval1.Interface()).Elem()
mval11 = &mval111
return d.valueFromTree(reflect.TypeOf(mval1.Interface()).Elem(), t, mval11)
}
return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval)
case []*Tree:
if isTreeSequence(mtype) {