Handle anonymous structs (#281)

Handle anonymous structs during Unmarshal.

Fixes #279
This commit is contained in:
Kamil Samigullin
2019-05-30 06:55:49 +03:00
committed by Thomas Pelletier
parent 728039f679
commit dba45d427f
2 changed files with 52 additions and 0 deletions
+9
View File
@@ -604,6 +604,15 @@ func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value,
}
mval.Field(i).Set(reflect.ValueOf(val))
}
// save the old behavior above and try to check anonymous structs
if !found && opts.defaultValue == "" && mtypef.Anonymous && mtypef.Type.Kind() == reflect.Struct {
v, err := d.valueFromTree(mtypef.Type, tval)
if err != nil {
return v, err
}
mval.Field(i).Set(v)
}
}
}
case reflect.Map: