Im trying to migrate from json.net to microsoft's json and found something that behaves very differently.
Let's use this simplified example:
public interface IName
{
string Name { get; set; }
}
public class Person : IName
{
public string Name { get; set; }
public int Age { get; set; }
}
public void Foo()
{
IName p = new Person {Age = 4, Name = "Waldo"};
var s1 = System.Text.Json.JsonSerializer.Serialize(p); // --> {"Name":"Waldo"}
var s2 = Newtonsoft.Json.JsonConvert.SerializeObject(p); // --> {"Name":"Waldo","Age":4}
}
Microsoft's Serializers serializes properties from IName JSON.NET serializes properties from Person
Is there a way to configure it so that it would work like JSON.NET? The options that I could pass do not indicate that this is configurable. Did I overlook something?