You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An JsonSerializationException is thrown with message Could not create an instance of type Base1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'Kind', line 1, position 8.`
Steps to reproduce
varsettings=newJsonSerializerSettings();settings.Converters.Add(JsonSubtypesConverterBuilder.Of(typeof(Base<>),"Kind")// type property is only defined here.RegisterSubtype(typeof(Nested1<>),"1").RegisterSubtype(typeof(Nested2<>),"2").SerializeDiscriminatorProperty()// ask to serialize the type property.Build());varjson=JsonConvert.SerializeObject(newNested1<int>{Value=42,},settings);// {"Kind":"1","Value":42}var@base=JsonConvert.DeserializeObject<Base<int>>(json,settings);// JsonSerializationException. Could not create an instance of type Base`1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'Kind', line 1, position 8.
The text was updated successfully, but these errors were encountered:
Source/destination types
Source/destination JSON
Expected behavior
Deserialization succeeds
Actual behavior
An JsonSerializationException is thrown with message
Could not create an instance of type Base
1[System.Int32]. Type is an interface or abstract class and cannot be instantiated. Path 'Kind', line 1, position 8.`Steps to reproduce
The text was updated successfully, but these errors were encountered: