mirror of https://github.com/goccy/go-json.git
Fix processing of anonymous field
This commit is contained in:
parent
45acfe9424
commit
cdf2498285
|
@ -622,7 +622,6 @@ type structFieldPair struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Encoder) anonymousStructFieldPairMap(typ *rtype, tags structTags, valueCode *structFieldCode) map[string][]structFieldPair {
|
func (e *Encoder) anonymousStructFieldPairMap(typ *rtype, tags structTags, valueCode *structFieldCode) map[string][]structFieldPair {
|
||||||
//fmt.Println("type = ", typ, "valueCode = ", valueCode.dump())
|
|
||||||
anonymousFields := map[string][]structFieldPair{}
|
anonymousFields := map[string][]structFieldPair{}
|
||||||
f := valueCode
|
f := valueCode
|
||||||
var prevAnonymousField *structFieldCode
|
var prevAnonymousField *structFieldCode
|
||||||
|
|
|
@ -10,9 +10,15 @@ func getTag(field reflect.StructField) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isIgnoredStructField(field reflect.StructField) bool {
|
func isIgnoredStructField(field reflect.StructField) bool {
|
||||||
if field.PkgPath != "" && !field.Anonymous {
|
if field.PkgPath != "" {
|
||||||
// private field
|
if field.Anonymous {
|
||||||
return true
|
if !(field.Type.Kind() == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct) && field.Type.Kind() != reflect.Struct {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// private field
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tag := getTag(field)
|
tag := getTag(field)
|
||||||
if tag == "-" {
|
if tag == "-" {
|
||||||
|
|
Loading…
Reference in New Issue