Exemplo n.º 1
0
        public void ArgumentDeserialization_Honors_JsonPropertyName()
        {
            Point_MembersHave_JsonPropertyName point = new Point_MembersHave_JsonPropertyName(1, 2);

            string json = JsonSerializer.Serialize(point);

            Assert.Contains(@"""XValue"":1", json);
            Assert.Contains(@"""YValue"":2", json);

            point = Serializer.Deserialize <Point_MembersHave_JsonPropertyName>(json);
            point.Verify();
        }
Exemplo n.º 2
0
        public void ArgumentDeserialization_Honors_JsonPropertyName_CaseInsensitiveWorks()
        {
            string json = @"{""XVALUE"":1,""yvalue"":2}";

            // Without case insensitivity, there's no match.
            Point_MembersHave_JsonPropertyName point = Serializer.Deserialize <Point_MembersHave_JsonPropertyName>(json);

            var options = new JsonSerializerOptions {
                PropertyNameCaseInsensitive = true
            };

            point = Serializer.Deserialize <Point_MembersHave_JsonPropertyName>(json, options);
            Assert.Equal(1, point.X);
            Assert.Equal(2, point.Y);
        }