{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/serializr/issues/33","repository_url":"https://api.github.com/repos/mobxjs/serializr","labels_url":"https://api.github.com/repos/mobxjs/serializr/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/serializr/issues/33/comments","events_url":"https://api.github.com/repos/mobxjs/serializr/issues/33/events","html_url":"https://github.com/mobxjs/serializr/issues/33","id":204687601,"number":33,"title":"Polymorphism and deserialization","user":{"login":"fabsantini","id":15570621,"avatar_url":"https://avatars2.githubusercontent.com/u/15570621?v=3","gravatar_id":"","url":"https://api.github.com/users/fabsantini","html_url":"https://github.com/fabsantini","followers_url":"https://api.github.com/users/fabsantini/followers","following_url":"https://api.github.com/users/fabsantini/following{/other_user}","gists_url":"https://api.github.com/users/fabsantini/gists{/gist_id}","starred_url":"https://api.github.com/users/fabsantini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabsantini/subscriptions","organizations_url":"https://api.github.com/users/fabsantini/orgs","repos_url":"https://api.github.com/users/fabsantini/repos","events_url":"https://api.github.com/users/fabsantini/events{/privacy}","received_events_url":"https://api.github.com/users/fabsantini/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-01T19:54:57Z","updated_at":"2017-03-02T11:00:46Z","closed_at":null,"body":"Hi,\r\n\r\nI have this small example: B and C are classes that extend the base class A. The serialization portion works just fine. However, once I retrieve the serialized object \"o\" later on, I have no idea what model schema to use for the deserialization portion (it could be B or C). Can I deserialize polymorphic classes?\r\n\r\nPlease, consider that I am new to serializr!\r\n \r\n```\r\nclass A {\r\n    @serializable public a: string;\r\n\r\n    constructor(aV: string) {\r\n        this.a = aV;\r\n    }\r\n}\r\n\r\nclass B extends A {\r\n    @serializable public b: string;\r\n\r\n    constructor(aV: string, bV: string) {\r\n\r\n        super(aV);\r\n        this.b = bV;\r\n    }\r\n}\r\n\r\nclass C extends A {\r\n    @serializable public c: string;\r\n    @serializable public cn: number;\r\n\r\n    constructor(aV: string, cV: string, cnV: number) {\r\n\r\n        super(aV);\r\n        this.c = cV;\r\n        this.cn = cnV;\r\n    }\r\n}\r\n\r\ndescribe('test', () => {\r\n\r\n    it('test', () => {\r\n\r\n        let bb: B = new B(\"vaB\", \"vb\");\r\n        let cc: C = new C(\"vaC\", \"vc\", 1);\r\n        let o: any = serialize(cc);\r\n\r\n        console.log(o);\r\n        console.log(deserialize(B, o)); // <--- What should I use for model schema?\r\n    });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/mobxjs/serializr/issues/comments/283623216","html_url":"https://github.com/mobxjs/serializr/issues/33#issuecomment-283623216","issue_url":"https://api.github.com/repos/mobxjs/serializr/issues/33","id":283623216,"user":{"login":"mweststrate","id":1820292,"avatar_url":"https://avatars3.githubusercontent.com/u/1820292?v=3","gravatar_id":"","url":"https://api.github.com/users/mweststrate","html_url":"https://github.com/mweststrate","followers_url":"https://api.github.com/users/mweststrate/followers","following_url":"https://api.github.com/users/mweststrate/following{/other_user}","gists_url":"https://api.github.com/users/mweststrate/gists{/gist_id}","starred_url":"https://api.github.com/users/mweststrate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweststrate/subscriptions","organizations_url":"https://api.github.com/users/mweststrate/orgs","repos_url":"https://api.github.com/users/mweststrate/repos","events_url":"https://api.github.com/users/mweststrate/events{/privacy}","received_events_url":"https://api.github.com/users/mweststrate/received_events","type":"User","site_admin":false},"created_at":"2017-03-02T11:00:46Z","updated_at":"2017-03-02T11:00:46Z","body":"See also #30, this seems to solve your case nicely? cc @JordinKee"}}
{"actor":{"display_login":"mweststrate"}}