Parse Google Protocol Buffers datagram without .proto file?

后端 未结 1 1122
-上瘾入骨i
-上瘾入骨i 2021-01-05 14:32

is it possible to parse an incoming google protocol buffers datagram without any .proto file? I merely now its been serialized using protocol buffers but have no idea about

相关标签:
1条回答
  • 2021-01-05 15:02

    protoc --decode_raw < my_file

    You need to take the following things into account when inspecting the output:

    • None of the field names are visible, just the tag numbers.
    • All varint-fields are shown as integers. This is ok for most types, but sint* will appear in the "zigzagged" format.
    • Doubles and floats will be shown as hex.
    • Bytes, string fields and submessages all appear the same, i.e. just a bunch of bytes.

    If you want to decode the messages programmatically, you can write your own .proto file after you have figured out what the fields mean using the above method.

    0 讨论(0)
提交回复
热议问题