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
}

Reply via email to