This commit is contained in:
John Guo
2023-07-13 21:15:07 +08:00
committed by GitHub
parent ce72f9a84b
commit 6d7edb1479

View File

@ -255,10 +255,21 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in
dataMap = make(map[string]interface{})
)
for _, k := range mapKeys {
var (
mapKeyValue = reflectValue.MapIndex(k)
mapValue interface{}
)
if mapKeyValue.IsZero() {
// in case of:
// exception recovered: reflect: call of reflect.Value.Interface on zero Value
mapValue = reflect.New(mapKeyValue.Type()).Elem()
} else {
mapValue = mapKeyValue.Interface()
}
dataMap[String(k.Interface())] = doMapConvertForMapOrStructValue(
doMapConvertForMapOrStructValueInput{
IsRoot: false,
Value: reflectValue.MapIndex(k).Interface(),
Value: mapValue,
RecursiveType: in.RecursiveType,
RecursiveOption: in.RecursiveType == recursiveTypeTrue,
Tags: in.Tags,