1
0
mirror of https://github.com/json-iterator/go.git synced 2025-02-01 19:14:29 +02:00

Unnamed struct literals

This commit is contained in:
Jarred Hawkins 2019-10-28 23:03:38 -07:00
parent 03217c3e97
commit 83f7b825b3
2 changed files with 6 additions and 1 deletions

View File

@ -341,7 +341,7 @@ func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
if ctx.onlyTaggedField && !hastag && !field.Anonymous() {
continue
}
if tag == "-" {
if tag == "-" || field.Name() == "_" {
continue
}
tagParts := strings.Split(tag, ",")

View File

@ -60,6 +60,7 @@ func init() {
(*SameLevel2NoTags)(nil),
(*SameLevel2Tagged)(nil),
(*EmbeddedPtr)(nil),
(*UnnamedLiteral)(nil),
)
}
@ -231,3 +232,7 @@ type EmbeddedPtrOption struct {
type EmbeddedPtr struct {
EmbeddedPtrOption `json:","`
}
type UnnamedLiteral struct {
_ struct{}
}