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
using System;
using NewtonsoftJson = Newtonsoft.Json.JsonConvert;
using SystemJson = System.Text.Json.JsonSerializer;
public interface Empty { }
public class ObjectA : Empty
{
public int id { get; set; }
}
class Program
{
static void Main(string[] args)
{
Empty a = new ObjectA()
{
id = 1,
};
Console.WriteLine("System.Text.Json, Serialize<Empty> => {0}", SystemJson.Serialize(a));
Console.WriteLine("System.Text.Json, Serialize<Object> => {0}", SystemJson.Serialize(a as object));
Console.WriteLine("Newtonsoft.Json, Serialize<Empty> => {0}", NewtonsoftJson.SerializeObject(a));
Console.WriteLine("Newtonsoft.Json, Serialize<Object> => {0}", NewtonsoftJson.SerializeObject(a as object));
}
}
using System;
using NewtonsoftJson = Newtonsoft.Json.JsonConvert;
using SystemJson = System.Text.Json.JsonSerializer;
public interface Empty { }
public class ObjectA : Empty
{
public int id { get; set; }
}
class Program
{
static void Main(string[] args)
{
Empty a = new ObjectA()
{
id = 1,
};
Console.WriteLine("System.Text.Json, Serialize<Empty> => {0}", SystemJson.Serialize(a));
Console.WriteLine("System.Text.Json, Serialize<Object> => {0}", SystemJson.Serialize(a as object));
Console.WriteLine("Newtonsoft.Json, Serialize<Empty> => {0}", NewtonsoftJson.SerializeObject(a));
Console.WriteLine("Newtonsoft.Json, Serialize<Object> => {0}", NewtonsoftJson.SerializeObject(a as object));
}
}
and output is:
Serialize<Empty>
will return{}
, is this the correct behavior?The text was updated successfully, but these errors were encountered: