serialization for general objects with getters and setters