解析不带.proto文件的Google协议缓冲区数据报? [英] Parse Google Protocol Buffers datagram without .proto file?

查看:195
本文介绍了解析不带.proto文件的Google协议缓冲区数据报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在没有任何.proto文件的情况下解析传入的Google协议缓冲区数据报?我现在只是使用协议缓冲区对其进行了序列化,但对IDL文件一无所知.

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 the IDL file.

我正在寻找一种通过某种反射来迭代任何值的方法?这可能吗?

I'm looking for a way to just iterate through any value by some sort of reflection? Is this possible?

谢谢!

推荐答案

protoc --decode_raw < my_file

检查输出时,需要考虑以下几点:

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

  • 所有字段名称均不可见,仅标记号可见.
  • 所有varint字段均显示为整数.多数类型都可以,但是sint *将以"zigzagged"格式显示.
  • 双精度和浮点将显示为十六进制.
  • 字节,字符串字段和子消息都显示相同,即只是一堆字节.

如果要以编程方式解码消息,则可以在使用上述方法弄清楚字段的含义之后编写自己的.proto文件.

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.

这篇关于解析不带.proto文件的Google协议缓冲区数据报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆