Learn to serialize HashMap using Google Gson library. Also learn to deserialize JSON string to HashMap containing custom Objects using Gson such that field values are copied into appropriate generic types. These conversion can be used to create deep clone of HashMap. 1. Serialize HashMap containing generic types to JSON Serializing a hashmap to JSON […]
You may need custom serialization in java in may cases. For example, you have legacy java classes which you are not willing to modify for any reason. There can be some design constraints as well. Or even simply, the class is expected to be changed in future releases which could break the deserialization of previously […]
XMLEncoder class is used to serialize or encode a java object into XML file, while XMLDecoder is used to deserialize the xml file back to java object. Learn to use them in detail.
Knowing the difference between Externalizable vs Serializable is important in two aspects, one – if could be asked as an interview question, two – you can use the knowledge to make better informed decision for performance improvement for applying serialization into your application.
You can achieve more efficient serialization by implementing Externalizable interface and overriding it’s methods writeExternal() and readExternal().