On 2011-07-21 09: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

Have a look at Orange: http://www.dsource.org/projects/orange
I'm in a middle of a complete rewrite but you can use a previous version (if it still works) or look at the code.

--
/Jacob Carlborg

Reply via email to