コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }