Skip to content

Instantly share code, notes, and snippets.

@xmsi
Created December 30, 2024 04:59
Show Gist options
  • Save xmsi/aba0cc50fbb98a1d827dc014b953f8eb to your computer and use it in GitHub Desktop.
Save xmsi/aba0cc50fbb98a1d827dc014b953f8eb to your computer and use it in GitHub Desktop.
Serialization

Author: Gemini

Think of it like this:

Imagine building a Lego car. You have all the different bricks and pieces put together to form the car. Serialization is like taking that Lego car apart and putting all the bricks into a box. You can then ship that box to someone else, and they can use the instructions (the serialization format) to rebuild the exact same car from the bricks.

Common uses of serialization

Saving objects to files: You can serialize objects and save them to files on your hard drive, allowing you to load them back into your program later. Sending objects over a network: Serialization is essential for sending objects between different computers or applications, such as in web services or distributed systems. Storing objects in a database: Some databases allow you to store serialized objects, making it easier to persist complex data structures. Deserialization

The reverse process of serialization is called deserialization. This is where you take the serialized data (the stream of bytes) and reconstruct the original object in memory.

Common serialization formats

  • JSON (JavaScript Object Notation): A human-readable text-based format widely used for data exchange on the web.
  • XML (Extensible Markup Language): Another text-based format that uses tags to represent data.
  • Binary formats: More compact and efficient formats that are not human-readable but can be faster to process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment