C#C
C#7mo ago
Cat4Life

✅ Can somone help me figure out why this doesn't deserialize?

public class Base
{
public int baseProp1;
}

public class Derived : Base
{
public string derivedProp;
}

var s = "{ "baseProp1": 1, "derivedProp": "foo"}";
var o = JsonSerializer.Deserialize<Derived>(s);

No exception is thrown but the values are 0 and null in the object o.
Was this page helpful?