aidanvii
10/28/2021, 7:38 AMJsonClassDiscriminator
doesn’t work on interfaces. The only way I can get polymorphic serialisation/deserialisation to work with interfaces is to register a polymorphic serialiser for it manually (as the docs specify). This ignores JsonClassDiscriminator
though, it only seems to work when the discriminator is the default key: type
ephemient
10/28/2021, 8:33 AM@JsonClassDiscriminator
+ PolymorphicSerializer
works for me; when I build and run this snippet, it produces{
"__type": "example.Bar"
}
EDIT: I thought this was running as expected when I wrote it, but it doesn't work for me anymore. I must have mixed it up with the Container
example below.ephemient
10/28/2021, 8:33 AMaidanvii
10/28/2021, 9:38 AMaidanvii
10/28/2021, 10:29 AMephemient
10/28/2021, 8:27 PMPolymorphicSerializer
seems to not recognize the annotation, @JsonClassDiscriminator
is only handled inside JSON.ephemient
10/28/2021, 8:30 PM