Serializing a class with objects