Status of std.serialization?

Jacob Carlborg doob at me.com
Fri Jun 21 19:09:31 UTC 2019


On 2019-06-21 09:22, JN wrote:

> Serialization can be tricky to make. Sure, at first you can be like
> "just use tupleof/static foreach/_allMembers and you have your
> serialization, D is so easy and awesome!". But then you hit some tougher
> usecases for serialization:
>
> - adding serialization support for custom types (especially ones you
> can't modify)
> - serializing/deserializing polymorphic types by base class reference
> - multiple formats - json/xml/yaml/binary

All these are supported by Orange [1]. Although only one format (XML) is 
currently implemented.

> I think any std.serialization attempt would need to have a modular
> approach with at least two modules. One module would be output-format
> agnostic and responsible for annotations. Marking variables which should
> be serialized, ones that shouldn't, ones that should be but with a
> different name, and with some form of serializeTo/deserializeFrom
> methods. The other module would be output format specific, something
> like XmlSerialization, which takes the definitions created by the first
> module and converts the data from/to the expected format.

That's exactly how Orange is implemented [1]

[1] http://github.com/jacob-carlborg/orange/

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list