Junior — Middle
Can you explain what the process of data deserialization means?
sobes.tech AI
Answer from AI
Deserialization is the process of converting data from a format suitable for storage or transmission (such as JSON, XML, binary format) back into an object in the program's memory.
For example, if an object was serialized into a JSON string for transmission over a network, deserialization converts this string back into an object with the same properties.
In Java, deserialization is often associated with restoring an object from a byte stream, for example, using the Serializable interface and the ObjectInputStream class.
Example of deserializing an object:
FileInputStream fileIn = new FileInputStream("person.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
Person person = (Person) in.readObject();
in.close();
fileIn.close();
Here, an object of class Person is restored from the file person.ser.