mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:18:31 +02:00
fix: non-struct anonymous field unmarshaling
This commit is contained in:
@@ -79,13 +79,15 @@ func flattenFields(t reflect.Type) []*field {
|
|||||||
f.marshal = appendMarshal
|
f.marshal = appendMarshal
|
||||||
}
|
}
|
||||||
if structField.Anonymous {
|
if structField.Anonymous {
|
||||||
if structField.Type.Kind() == reflect.Pointer {
|
t := structField.Type
|
||||||
f.inner = flattenFields(structField.Type.Elem())
|
if t.Kind() == reflect.Pointer {
|
||||||
|
t = t.Elem()
|
||||||
f.omitEmpty = true
|
f.omitEmpty = true
|
||||||
} else {
|
|
||||||
f.inner = flattenFields(structField.Type)
|
|
||||||
}
|
}
|
||||||
f.hasInner = len(f.inner) > 0
|
if t.Kind() == reflect.Struct {
|
||||||
|
f.inner = flattenFields(t)
|
||||||
|
f.hasInner = len(f.inner) > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fields = append(fields, f)
|
fields = append(fields, f)
|
||||||
if f.omitEmpty {
|
if f.omitEmpty {
|
||||||
|
|||||||
Reference in New Issue
Block a user