Polymorphic serialization and de-serialization.