序列化和反序列化
一、序列化:
就是将内存中的对象转换为字节序列,方便持久化到磁盘或者网络传输
SerializeToString()
: serializes the message and returns it as a string. Note that the bytes are binary, not text; we only use thestr
type as a convenient container.
二、反序列化:
就是将字节序列转换为内存中的对象
ParseFromString(data)
: parses a message from the given string.