我知道有一种方法可以在protobuf中序列化一条消息。但有没有一种简单的方法可以打印出protobuf消息中的值?像Java中的toString()方法?
感谢。
答案 0 :(得分:3)
protocol buffer basics -- Java
引自该链接,请检查standard message methods
:
标准消息方法
每个消息和构建器类还包含许多其他方法,可用于检查或操作整个消息,包括:
isInitialized(): checks if all the required fields have been set.
toString(): returns a human-readable representation of the message, particularly useful for debugging.
mergeFrom(Message other): (builder only) merges the contents of other into this message, overwriting singular fields and concatenating repeated ones.
clear(): (builder only) clears all the fields back to the empty state.