示例#1
0
        public void AnyConversion_JSON_Serialization_Deserialization()
        {
            var response = new Response()
            {
                Name = "test"
            };

            var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);

            var any  = TypeConverters.ToJsonAny(response, options);
            var type = TypeConverters.FromJsonAny <Response>(any, options);

            type.Should().BeEquivalentTo(response);
            any.TypeUrl.Should().Be(string.Empty);
            type.Name.Should().Be("test");
        }