Given the following polymorphic type hierarchy:
[JsonConverter(typeof(PolymorphicConverter<Base>))]
public record Base
{
private Base() {}
public record A(string Value) : Base;
public record B(int Foobar) : Base;
public record C(Base Recursive) : Base;
}
with the desired serialized json for e.g. A:
{
"type": "A",
"content": {
"value": "jalla"
}
}
Is it possible to create an implementation for PolymorphicConverter that’s not tied to the type Base
, is performant and is thread safe?
New contributor
1