System.Text.Json.JsonException: A possible object cycle was detected which is not supported

When you use System.Text.Json.JsonSerializer to serialize an object that has a cycle, you’ll get the following exception: System.Text.Json.JsonException: A possible object cycle was detected which is not supported. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 0. This is the same problem … Read more System.Text.Json.JsonException: A possible object cycle was detected which is not supported

Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property

Problem When you try to serialize an object using Newtonsoft.Json and there’s a circular reference, you get the following exception: Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property For example, I have a Parent class and Child class. The Parent object has a reference to a Child object, which has a back reference to the Parent … Read more Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property