Sandeep Talabathula

Differences between Object Serialization and Deserialization?

November 20, 2009

Serialization = putting the relevant state of the object into a streamable representation. That can mean converting it to a byte stream. This does not necessarily include copying every member variable into the stream.

Deserialization = restoring an object from a serial representation and ensuring the invariants of the object. Deserialization can be thought of a separate constructor for the object.

Serialization generally refers to creating a version of the data (rather than the objects) that can be used for storage (perhaps in a file), for transfer over a network, or perhaps just for transfer between processes / AppDomains /etc on a single machine.

Serialization typically means writing the data as a string (think: xml / json) or as raw binary (a byte[] etc). Deserialization is the reverse process; taking the raw data (from a file, from an incoming network socket, etc) and reconstructing the object model.

The difference between using a db is that it has no intrinsic tabular layout, and no real tie to a database; the data can be any shape, and tends to map more closely to the object-oriented layout than to the rows/columns nature of tables.

Most platforms have a range of serialization tools. For example, it sounds like you're talking about .NET - so BinaryFormatter (.NET-specific), XmlSerializer, DataContractSerializer, Json.NET and protobuf-net / dotnet-protobufs would all qualify.

Read one good article here!


Originally posted on Things on Tech.

← All posts