views:

101

answers:

1

I have to get the message structure of a protobuf message transfered to me without the message's definition. Using UnknownFieldSet methods, I was able to get a string representation of the message as below:

1: "a"
2: {
   3:"b"
   4:"c"
}

What data structure does field 2 represent ? Using UnknownFieldSet.Field.getGroupList i was able to get the content of field 3 and 4, does that means field 2 has the "deprecated" group structure ?

+2  A: 

If you posted the raw binary data we could tell you - or you could look at the protocol buffer encoding documentation. If you see a field with a wire type of 3, that indicates a group.

I'm not as familiar with the UnknownFieldSet API as I probably should be, but it does sound like you're dealing with a group.

On the other hand, I'd expect most of the uses of groups to be internal to Google - where did this data come from? Admittedly there's nothing to stop people from using the deprecated group format instead of embedded messages, but I would hope that few are doing so...

Is there any reason you can't ask for the .proto file involved? While some information can certainly be gleaned from protocol buffers without their definitions, they're really designed to be used in situations where both ends do know the message format - although possibly different versions.

Jon Skeet
thanks, it's indeed a group.
dqminh