Serializing mixed type arrays with protobuf

939 views
Skip to first unread message

Flo Loferer

unread,
Feb 11, 2016, 1:43:10 PM2/11/16
to Protocol Buffers
I have an array containing two different object types.

Is there a chance to serialize this array with protobuf?
What would the message definition look like?

Josh Haberman

unread,
Feb 19, 2016, 6:54:28 PM2/19/16
to Protocol Buffers
If you want an array of mixed-type data, the best option in protobuf is something like this:

message Types {
  oneof types {
    Foo foo = 1;
    Bar bar = 2;
  }
}

message Container {
  repeated Types list = 1;
Reply all
Reply to author
Forward
0 new messages