Join GitHub today
Allow policy-based serialization #937
An explicit Policy parameter allows to customize serialization of types
The PR is not ready yet, needing documentation and tests, but it's working, so I would like some feedback.
An usage example (that pushed me to write the code) is serializing objects synthesized by dproto, which can be done with such a policy:
which transforms the serialized form from:
(Actually, serializing dproto objects without a custom policy fails, due to https://issues.dlang.org/show_bug.cgi?id=12363 ; but it would look like the former if it worked)
I also would have liked to add a template parameter (defaulted to DefaultPolicy) to
It should be possible to compose policies with something like
but I still have to work on it, and I wonder if it would be possible to create a general policy composer.