DEV Community

loading...
Cover image for What is Serialization?

What is Serialization?

courseprobe profile image Course Probe ・2 min read

Simply speaking Serialization is a process of converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage.

Deserialization is the exact opposite — Fetch a stream of bytes from network or persistence storage and convert it back to the Object with the same state.

The thing to understand is how those stream of bytes are interpreted or manipulated so that we get the exact same Object/ same state. There are various ways to achieve that. Some of them are -

  1. XML: Convert Object to XML, transfer it over a network or store it in a file/db. Retrieve it and convert it back to the object with same state. In Java we use JAXB(Java architecture for XML binding) library.(From java 6 it comes bundled with JDK).

  2. JSON: Same can be done by converting the Object to JSON (JavaScript Object notation). Again there is GSON library that can be used for this.

  3. Or we can use the Serialization that is provided by the OOP language itself. For example, in Java you can serialize an Object my making it implement Serializable interface and writing to Object Stream.

Additional Resources:

Akka Serialization with Scala | Rock the JVM

JavaScript, jQuery, and JSON

References:

1- https://stackoverflow.com/questions/633402/what-is-serialization


Discussion (2)

pic
Editor guide
Collapse
delta456 profile image
Swastik Baranwal

Nice article!

Collapse
cescquintero profile image
Francisco Quintero 🇨🇴

Useful definition :)