Dump Protobuf Messages Without A Schema
For anyone working with gRPC or Protobuf messages that need to decode the binary message format, but don’t have or don’t want to find the actual schema, this invocation of protoc
works great:
protoc --decode_raw
It takes a binary Protobuf message from STDIN and produces a text-based output showing the message structure in a human readable format. You could say it almost looks like JSON, but since there’s no type information, there are no field names, and all you have are field numbers and value (so don’t throw away your schemas just yet):
1 {
1: "example"
2: 123
3 {
1: "this is a nested message"
2: "<-- this is the field number"
}
3 {
1: "fields numbers appearing twice indicate a repeatable field"
2: "in short a list"
}
}
There are some good online tools that do this too: this is one I use quite often. But of you need to do this within a script or something, this approach works quite well.