Implement serialize any class macro.