JsonContentPolymorphicSerializer
should provide a non-final selectSerializer
#2622
Labels
JsonContentPolymorphicSerializer
should provide a non-final selectSerializer
#2622
What is your use-case and why do you need this feature?
JsonContentPolymorphicSerializer
is a very useful abstract class and I have used it quite a few times, but now I have a slightly different problem that cannot be fixed using it.I'm basically trying to support serialization on a
Map<String, Any>
whereAny
could beString
or a a few classes that belong to a polymorphic hierarchy. (That would be a perfect case for aString | MyObject
union type, but we don't have that yet).This is how I implemented it:
Everything works great for deserialization if I have the correct payload, but for serialization we end up with a payload without the discriminator value as the serializer of the instance is used instead of the
MySealedHierarchy
one.Describe the solution you'd like
If we had something like
we could actually override the default serializer to consider the value type:
The text was updated successfully, but these errors were encountered: