It sounds like you actually have the message class available, not just a
serialized instance of the message. In that case, you can derive the
original type by reading the generated code. If you only have a compiled
copy of the class, you can derive the type from its descriptor -- use
MessageType.
You can decode the protocol buffer with just wire type + tag number, but you
won't know the original types without a proto definition. Everything would
be treated as an unknown field. You could access these by iterating through
the UnknownFieldSet, but again, you can't recover the original types.
Hi Marc,
Thanks for the clarification. If the actual .proto was there, i would not
have posted that question [?] at the first place. Anyways, to decode a
protocol buffer, is it not enough to have just the wire type + tag number
combination? (except of course, handling of the sub-messages-ness and
If you treat it as a string (UTF8), you are likely to get garbage. If you
treat it as a byte[], then you just get a BLOB - you don't lose anything,
but you might not be showing some more detail that you could show.
You could, however, check for likely-sub-message-ness - i.e. after getting
the leng