My C# program is running into StackOverflowException, when I try to serialize object with similar structure like this:
public class Model
{
public int Id { get; set; }
public string Name { get; set; }
public string SurName { get; set; }
}
List list = new List();
list.Add(new Model { Id = 1, Name = "Jon", SurName = "Snow"});
var stringJson = JsonConvert.SerializeObject(list, new JsonSerializerSettings
{
PreserveReferencesHandling = PreserveReferencesHandling.Objects
});