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
  •  | 
  •  

Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top