# proto: int32 字段的值无效: "abc"

- **ID:** `go/protobuf-json-marshal-invalid-value`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

为整数字段提供的 JSON 值不是有效的整数，导致 protojson 解组失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   // Ensure the JSON field is a number, not a string.
// If it's a string, parse it and set the field manually.
   ```
2. **** (85% 成功率)
   ```
   opts := protojson.UnmarshalOptions{AllowPartial: true}
err := opts.Unmarshal(data, msg)
   ```

## 无效尝试

- **** — Changing the type breaks compatibility and may not be semantically correct. (80% 失败率)
- **** — Custom parsers are error-prone and don't integrate with protobuf well. (70% 失败率)
