Protobuf groups and messages

Viewed 277

I have a question regarding message and group intercompatibility. Can data encoded with first proto be decoded with second proto structures? Or they have different wire formats and are not intercompatible?

First proto:

message SearchResponse {
  repeated group Result = 1 {
    required string url = 2;
    optional string title = 3;
    repeated string snippets = 4;
  }
}

Second proto:

message SearchResponse {
  message Result {
    required string url = 2;
    optional string title = 3;
    repeated string snippets = 4;
  }

  repeated Result result = 1;
}
1 Answers

group uses a different encoding style, and most serializers will outright refuse to work compatibly between them. Since you specifically added the tag, I will note that protobuf-net is a bit more forgiving here, and should work interchangeably, but I probably wouldn't get into the habit of doing that very often. As a side note, group is largely deprecated by Google and the details don't even appear in the encoding specification any more (it just mentions that they exist and are deprecated).

Related