public static void SimpleTypeCycle() { TestClassWithArrayOfElementsOfTheSameClass obj = new TestClassWithArrayOfElementsOfTheSameClass(); // A cycle in just Types (not data) is allowed. string json = JsonSerializer.Serialize(obj); Assert.Equal(@"{""Array"":null}", json); }
public static void WriteTestClassWithArrayOfElementsOfTheSameClassWithoutCyclesDoesNotFail() { TestClassWithArrayOfElementsOfTheSameClass obj = new TestClassWithArrayOfElementsOfTheSameClass(); //It shouldn't throw when there is no real cycle reference, and just empty object is created string json = JsonSerializer.ToString(obj); Assert.Equal(@"{}", json); }