mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-05 14:24:02 +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
|
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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue