protobufs 格式的原始解码器 [英] raw decoder for protobufs format

查看:77
本文介绍了protobufs 格式的原始解码器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一种方法将二进制 protobuf 消息转换为包含数据的人类可读描述,而无需使用 .proto 文件.

I'd like to find a way to convert a binary protobuf message into a human readable description of the contained data, without using the .proto files.

背景是我有一个 .proto 消息,它被 Android 上的解析器拒绝,但不完全清楚原因.我可以手动浏览消息,但它相当乏味.

The background is that I have a .proto message that it being rejected by the parser on Android, but it's not entirely clear why. I could go through the message by hand, but it's rather tedious.

我尝试了 protoc --decode_raw,但它只是给出错误无法解析输入.".我在谷歌上搜索希望/期望有人会做一个很好的网络实用程序,可以做到这一点,但没有发现任何明显的东西.

I tried protoc --decode_raw, but it just gives the error "Failed to parse input.". I google hoping/expecting someone would have done a nice web utility that might do this, but haven't found anything obvious.

我只是希望得到一些输出,如:

I'm just hoping to get some output like:

field 1: varint: 128
field 4: string: "foo"

欢迎任何指向正确方向的指针!

Any pointers in the right direction would be most welcome!

推荐答案

你可以尝试通过wireshark插件强制它,或者你可以借用一些实现的阅读器"部分(我知道我将如何做到这一点例如,在 C# 中,但我怀疑这就是您的意思).

You could try forcing it through the wireshark plugin, or you could probably borrow the "reader" part of some of the implementations (I know how I would do this in C#, for example, but I doubt that is what you meant).

但是,要小心 - 协议缓冲区中的字符串并不真正意味着字符串" - 它可能是:

However, be cautious - string in protocol buffers doesn't really mean "string" - it could be:

  • 一个 UTF-8 字符串
  • 原始 BLOB 的任意数据
  • 子消息
  • 一个打包"的数组
  • (可能是我忘记的其他东西)

这篇关于protobufs 格式的原始解码器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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