Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are object serialization and deserialization?

Tags:

What are object serialization and deserialization?

What difference does serialization have with normal techniques like reading an object's properties and then filling a DataRow's columns with them and finally saving the DataRow in DB?

like image 310
odiseh Avatar asked Sep 01 '09 05:09

odiseh


People also ask

What is meant by object serialization?

To serialize an object means to convert its state to a byte stream so way that the byte stream can be reverted back into a copy of the object. A Java object is serializable if its class or any of its superclasses implements either the java. io. Serializable interface or its subinterface, java.

What is the use of serialization and deserialization in Java?

Serialization in Java allows us to convert an Object to stream that we can send over the network or save it as file or store in DB for later usage. Deserialization is the process of converting Object stream to actual Java Object to be used in our program.

What is serialization and deserialization in API?

Serialization is a conversion of the state of a Java object to a byte stream and Deserialization is the reverse of it i.e. conversion of a byte stream to corresponding Java object. A serialized object can be stored in files, external sources, databases etc and can also be transferred over networks.

What is used for object deserialization?

An ObjectInputStream deserializes objects and primitive data written using an ObjectOutputStream. It creates an ObjectInputStream that reads from the specified InputStream. It reads an object from the input stream.


1 Answers

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.

like image 143
Marc Gravell Avatar answered Oct 06 '22 23:10

Marc Gravell