I'm working on an extension for https://github.com/13xforever/gvas-converter with the ability to parse UnrealEngine .sav files. (https://github.com/RagingLightning/gvas-converter/blob/master/GvasFormat/Gvas.cs)
I have three relevant classes:
public class Gvas
: main class to be deserialized, has a field public List<UEProperty> Properties = new List<UEProperty>();
public abstract class UEProperty
: base class for all possible Unreal Engine properties
with a field string Type
denoting which subclass the current one is
public class UEStringProperty : UEProperty
: fully functional class extending UEProperty
tailored to the String variant
When I deserialize the Gvas
object lie this:
Gvas data = JsonConverter.DeserialiteObject<Gvas>(<json-string>);
the deserializer tries to instantiate the UEProperty
class multiple times to populate the Properties
list and fails, since the class is abstract.
How can I tell the deserializer to instantiate a subclass based on th value of Type
(eg. instantiate UEStringProperty
when Type == "StringProperty"
)?