If proto Foo and proto Bar are exactly the same except the name, can I use Bar to parse serialized Foo messages?

StackOverflow https://stackoverflow.com/questions/22338949

  •  13-06-2023
  •  | 
  •  

If proto Foo and proto Bar are exactly the same except the name, can I use Bar to parse serialized Foo messages?

有帮助吗?

解决方案

Yes.

In general, you can always change names of things in protobufs without affecting the wire format, as long as you don't change numbers. (Though if you ever encode your protobuf to JSON or some similar encoding, names might matter there.)

In fact, Bar could even just contain a subset of the fields in Foo, since Protobuf backwards compatibility allows you to add and remove fields.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top