我知道有一种方法可以在 protobuf 中序列化消息。但是有没有一种简单的方法可以打印出 protobuf 消息中的值?类似于 Java 中的 toString() 方法?
谢谢。
从链接引用,检查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.
Run Code Online (Sandbox Code Playgroud)