compile time introspection and code generation - automatically serialize to json
Robert Clipsham
robert at octarineparrot.com
Thu Jul 21 01:20:49 PDT 2011
On 21/07/2011 08:57, Tobias Pankrath wrote:
> Hi everyone,
>
> I'm taking a look at D again and asked myself, if
> it is possible to write a template mixin or something
> similiar that automatically serializes an object to json.
>
> For example:
>
> class MyClass
> {
> string memberA;
> int memberB;
> MyClass memberC;
> mixin ToJson!MyClass;
> }
>
> should make possible to automatically output
> "someid" { "memberA" : "somestring",
> "memberB" : 12,
> memberC : "someotherid"};
>
> How could this be accomplished? I've found std.traits
> RepresentationTypeTupel but don't see how this would
> help me.
>
> Thanks,
>
> Tobias
>
>
Side note: If/when you finish this, you should definitely make a pull
request for phobos' std.json! This sort of thing would be incredibly useful!
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d-learn
mailing list