# error: json: cannot unmarshal object into Go value of type struct { Name string `json:"name"` }

- **ID:** `go/encoding-json-unmarshal-unknown-field`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

JSON数据包含结构体中未定义的字段，默认情况下encoding/json会忽略未知字段，但若结构体定义不匹配则报错。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   type MyStruct struct {
    Name string `json:"name"`
    Extra json.RawMessage `json:"-"`
}
   ```
2. **** (85% success)
   ```
   使用json.Decoder.DisallowUnknownFields()来捕获未知字段错误。
   ```

## Dead Ends

- **** — 不灵活，且当API变化时维护困难。 (50% fail)
- **** — 失去类型安全，需要手动类型断言，容易出错。 (70% fail)
