Implemented serialization and deserialization for User class.