mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fix: non-struct anonymous field unmarshaling
This commit is contained in:
parent
973a44ee07
commit
81a6ef9745
1 changed files with 7 additions and 5 deletions
|
@ -79,13 +79,15 @@ func flattenFields(t reflect.Type) []*field {
|
|||
f.marshal = appendMarshal
|
||||
}
|
||||
if structField.Anonymous {
|
||||
if structField.Type.Kind() == reflect.Pointer {
|
||||
f.inner = flattenFields(structField.Type.Elem())
|
||||
t := structField.Type
|
||||
if t.Kind() == reflect.Pointer {
|
||||
t = t.Elem()
|
||||
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)
|
||||
if f.omitEmpty {
|
||||
|
|
Loading…
Add table
Reference in a new issue