#393·grpcurl

JSON protobuf 编码不遵循字段掩码的正确格式

作者: RichieAHB创建于 2023年5月10日更新于 2025年9月30日

通过 gRPCurl 进行 protobuf 字段掩码的编码和解码是不正确的。protobuf 参考 定义了用逗号分隔的字符串列表来表示字段掩码,而 gRPCurl 仅将 JSON 和 protobuf 映射为任何其他 proto,并期望在对象的 paths 字段下获得字符串数组(即 repeated string paths)。这会在将 JSON 解码的 proto 传入 gRPCurl 时产生问题。看起来,原因是 gRPCurl 使用 jsonpb,这是一个已淘汰的库,在解码时 switch 方法中不包含 FieldMask。而更现代的 protobuf-go则包含了它

内容来源: fullstorydev/grpcurl