You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use an embedded struct via a pointer and omitempty tag on one of struct fields, fields on embedded struct which also tagged with omitempty are ignored in the output json, even if there is a value.
Not reproduced if structure A is used by value and not by reference
Not reproduced if MiddleName field is declared after Name field
Not reproduced if MiddleName field has value
Go: go1.20 segmentio/encoding/json: v0.3.6
The text was updated successfully, but these errors were encountered:
BlasterAlex
changed the title
Marshal applies omitempty tag to all fields of embedded struct
Marshal ignores fields on embedded struct when using an omitempty tag
May 29, 2023
If you use an embedded struct via a pointer and
omitempty
tag on one of struct fields, fields on embedded struct which also tagged withomitempty
are ignored in the output json, even if there is a value.Example code:
Example output:
Notes:
Go: go1.20
segmentio/encoding/json: v0.3.6
The text was updated successfully, but these errors were encountered: