为什么需要序列化?

249 阅读1分钟

在一个复杂对象中,数据是任意存储在内存中的。

  1. 我们如何存储这个对象到文件中呢?
  2. 我们如何传输这个对象到别的进程或者计算机中呢?

我们不能直接存储内存地址,因为我们无法去取它。

所以我们需要serialization!

serialization is the process of tranlating data structures or object state into a format that can be stored(for example, in a file or memory buffer) or transmitted (for expamle, across a network connection link) and reconstructed later (possibly in a different computer environment). -Wikkipedia object=> 序列化() =>(a human readable string/bytes array) or bytes(binary format)