# json: 无法将数组反序列化为结构体类型 struct { Name string }

- **ID:** `go/json-cannot-unmarshal-array-into-struct`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

JSON 数据是数组，但目标 Go 类型是结构体，导致类型不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.21 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Unmarshal into []struct{ Name string } if JSON is array: var data []struct{Name string}; json.Unmarshal([]byte(jsonStr), &data)
   ```
2. **** (85% 成功率)
   ```
   Use json.RawMessage to inspect first, then unmarshal accordingly.
   ```

## 无效尝试

- **** — Data not parsed, leads to nil values. (90% 失败率)
- **** — May not match API contract; breaks other code. (40% 失败率)
