public void WriteObjectWithList() { const string expected = @"{""IntList"":[1,2],""ObjectList"":[{""IntValue"":1},{""IntValue"":2}],""StringList"":[""a"",""b""]}"; ObjectWithList obj = new ObjectWithList { IntList = new List <int> { 1, 2 }, ObjectList = new List <IntObject> { new IntObject { IntValue = 1 }, new IntObject { IntValue = 2 } }, StringList = new List <string> { "a", "b" } }; JsonSerializerOptions options = new JsonSerializerOptions(); options.SetupExtensions(); string actual = JsonSerializer.Serialize(obj, obj.GetType(), options); Assert.Equal(expected, actual); }