(De)Serializing interfaces
nims via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 22 12:14:14 PDT 2015
I think interfaces are very powerful and I heavily use them. The
only problem I have with them is that serializing/deserializing
them to XML or JSON doesn't seem to work. So far I got to try
Orange and painlessjson. Using Orange all I got was a lot of
compiler errors. Painlessjson did compile normally but just
ignores all interface class members.
This is the code I tried (I apologize for not formatting it, I
have no idea how to do that):
interface MyInterface {
int GetA();
}
class Foo: MyInterface {
int a;
int GetA() { return a; }
}
// maybe add a class Bar later which implements the same interface
class Foobar {
MyInterface myBar = new Foo();
}
void main()
{
// serialize it
}
More information about the Digitalmars-d-learn
mailing list