# proto: (第 1 行:第 2 列): 在 pb.YourMessage 中未知字段 "unknown_field"

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

## 根因

JSON 输入包含 protobuf 消息中未定义的字段，且解组器配置为拒绝未知字段。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   import "google.golang.org/protobuf/encoding/protojson"
opts := protojson.UnmarshalOptions{DiscardUnknown: true}
err := opts.Unmarshal(data, msg)
   ```
2. **** (90% 成功率)
   ```
   // Add the field to your .proto file and regenerate.
// message YourMessage { string unknown_field = 1; }
   ```

## 无效尝试

- **** — This is a temporary fix; the field may reappear or be required by other clients. (60% 失败率)
- **** — encoding/json does not understand protobuf field names and will produce incorrect results. (80% 失败率)
