---
title: "unexported-serialization-fields"
description: "Detect serialization of structs with no exported fields."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Bad

```go
json.Marshal(struct{ name string }{name: name})
```

## Good

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

Source: https://strider.gempir.com/analyzers/unexported-serialization-fields/index.mdx
