I already have all this in Orange [1], which I'm in progress of adapting
to a package for Phobos.
...
This requires registering the subclass in some way. In my implementation
one needs to call:
Serializer.register!(Sub);
For full example see [2].
[1] https://github.com/jacob-carlborg/orange
[2] https://github.com/jacob-carlborg/orange/wiki/Base-Class
The problem with the way your doing it though is that it requires that the
library doing the deserialization is fully aware of the semantics used in
the serialization implementation, rather than just the syntax and
semantics of the selected serialization format.