# proto: (第1行:2): 未知字段 "unknownField" 在 jsonpb.Message 中

- **ID:** `go/protobuf-json-unmarshal-unknown-field`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

JSON 数据包含 protobuf 消息中未定义的字段。这可能发生在 JSON 模式与 proto 定义不同步时。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   // Option 1: Update proto and regenerate
// Option 2: Use jsonpb.Unmarshaler
unmarshaler := &jsonpb.Unmarshaler{AllowUnknownFields: true}
if err := unmarshaler.Unmarshal(strings.NewReader(jsonStr), &msg); err != nil {
    log.Fatal(err)
}
   ```
2. **** (85% 成功率)
   ```
   // Use a JSON schema validator or compare fields
// Or catch the error and log the unknown field for investigation
   ```

## 无效尝试

- **** — This may hide schema mismatches and lead to data loss or misinterpretation. (60% 失败率)
- **** — Not scalable and doesn't fix the underlying schema issue. (80% 失败率)
