Data format compatibility between protobuf versions
I was wondering if protocol buffer's serialized data format remains constant across protobuf compiler and client library versions.
开发者_如何学JAVAIn other words, do I need to use the same compiler version to generate my Python, Java, and C++ classes? And do these clients all need to use the same version of protobuf libraries?
This post sort of addresses my question, but its accepted answer is specific to the OP's protobuf version.
Yes, that is pretty much the idea. It shouldn't matter which library you use, as long as it follows the spec. Note that the same data can be represented in slightly different ways, for example field order should not matter to the client, and while it is common for clients to write fields in ascending order, it is explicitly required of clients to process fields in any order. All I'm saying here is that it might not be exactly the same bytes in the same order, but it should work fine from any client.
Note that some implementations might offer additional features (*cough* like mine offers inheritance support), intended for use primarily only within that single client. In that case, I would a: expect those features to be obvious when used, and b: it should always still produce a valid protobuf stream (you might just choose to ignore those fields, or support them as bytes
for the purpose of round-trip).
精彩评论