序列化和反序列化

一、序列化:

就是将内存中的对象转换为字节序列,方便持久化到磁盘或者网络传输

  • SerializeToString(): serializes the message and returns it as a string. Note that the bytes are binary, not text; we only use the str type as a convenient container.

 

二、反序列化:

就是将字节序列转换为内存中的对象

  • ParseFromString(data): parses a message from the given string.

 

posted @ 2019-09-20 13:59  Leophen  阅读(231)  评论(0编辑  收藏  举报