Skip to content

unexported-serialization-fields

Default severity: warning

The standard JSON and XML packages ignore unexported struct fields. Marshaling a non-empty struct with no exported fields produces empty data, and unmarshaling into it cannot populate anything.

Empty structs, promoted exported fields, and types with custom text, JSON, or XML serialization methods are accepted.

json.Marshal(struct{ name string }{name: name})
json.Marshal(struct{ Name string }{Name: name})