# json: 无法将数字反序列化为字符串类型的 Go 值

- **ID:** `go/json-unmarshal-type-mismatch`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

JSON 数据包含与目标 Go 字段类型不同的值，例如在期望字符串的地方出现了数字。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.14 | active | — | — |
| 1.15 | active | — | — |
| 1.16 | active | — | — |

## 解决方案

1. **** (80% 成功率)
   ```
   Define the struct field as interface{} and then type assert.
   ```
2. **** (85% 成功率)
   ```
   Use a custom UnmarshalJSON method to handle type conversion.
   ```

## 无效尝试

- **** — This only works if the field is of type json.Number, not string. (70% 失败率)
- **** — Tags do not change the type conversion. (90% 失败率)
