1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

fix #308 do NOT skip embedded structs without tag when OnlyTaggedField is set to true

This commit is contained in:
Adam Kiss
2018-10-29 11:59:34 +01:00
parent 05d041de10
commit a9403d25cd
2 changed files with 56 additions and 1 deletions

View File

@ -338,7 +338,7 @@ func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
for i := 0; i < structType.NumField(); i++ {
field := structType.Field(i)
tag, hastag := field.Tag().Lookup(ctx.getTagKey())
if ctx.onlyTaggedField && !hastag {
if ctx.onlyTaggedField && !hastag && !field.Anonymous() {
continue
}
tagParts := strings.Split(tag, ",")