What's the best way to handle json deserialization for many derived types? I have a class library with a bunch of simple dto classes that will be rapidly sent back and forth across multiple apps. They will be serialized as JSON, and may be in a list. The classes aren't really related to each other besides being a "command" for some action that the receiving apps will do, so while they will share a simple baseclass, each object has to be deserialized into the correct class so the apps can switch to the right action.
Does using an enum as an identifier make sense? I would have to make one for each class which seems annoying. I saw system.text.json has the $type discriminator that can be added, but only in .net 7+ and there's no guarantee the other apps will be on that. But I guess I could create a custom JsonConverter to read/write it
The serializaton/deserialization speed is important if that matters