# 错误：json：无法将 null 反序列化为字符串类型的 Go 值

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

## 根因

JSON 数据中的字段为 null，但对应的结构体字段是字符串类型，且未使用指针或处理 null 的方式。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use a pointer to string (*string) for nullable fields.
   ```
2. **** (90% 成功率)
   ```
   Implement a custom UnmarshalJSON method to handle null.
   ```

## 无效尝试

- **** — This loses type safety and may cause runtime type assertions to fail. (80% 失败率)
- **** — This is inefficient and may alter the meaning of the data. (70% 失败率)
