当前位置: 首页>>代码示例>>C#>>正文


C# JsonDeserializer.Deserialize方法代码示例

本文整理汇总了C#中Xunit.JsonDeserializer.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# JsonDeserializer.Deserialize方法的具体用法?C# JsonDeserializer.Deserialize怎么用?C# JsonDeserializer.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xunit.JsonDeserializer的用法示例。


在下文中一共展示了JsonDeserializer.Deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Ignore_Protected_Property_That_Exists_In_Data

		public void Ignore_Protected_Property_That_Exists_In_Data() {
			var doc = CreateJson();
			var d = new JsonDeserializer();
			var p = d.Deserialize<PersonForJson>(doc);

			Assert.Null(p.IgnoreProxy);
		}
开发者ID:restsharp,项目名称:RestSharp,代码行数:7,代码来源:JsonTests.cs

示例2: Can_Deserialize_JScript_Json_Dates

        public void Can_Deserialize_JScript_Json_Dates()
        {
            var doc = CreateJScriptDateJson();
            var d = new JsonDeserializer();
            var bd = d.Deserialize<Birthdate>(doc);

            Assert.Equal(new DateTime(1910, 9, 25, 9, 30, 25, DateTimeKind.Utc), bd.Value);
        }
开发者ID:CSharpByDesign,项目名称:RestSharp,代码行数:8,代码来源:JsonTests.cs

示例3: Can_Deserialize_Guid_String_Fields

        public void Can_Deserialize_Guid_String_Fields()
        {
            var doc = new JObject();
              doc["Guid"] = "b1457983-8c5c-4c11-b10e-58585ed646d2";

              var d = new JsonDeserializer();
              var p = d.Deserialize<PersonForJson>(doc.ToString());

              Assert.Equal(new Guid("b1457983-8c5c-4c11-b10e-58585ed646d2"), p.Guid);
        }
开发者ID:CSharpByDesign,项目名称:RestSharp,代码行数:10,代码来源:JsonTests.cs

示例4: Can_Deserialize_Json_MySql_Php_Date

        public void Can_Deserialize_Json_MySql_Php_Date()
        {
            var doc = new JObject();
              doc["StartDate"] = "2010-01-10 14:23:54";

              var d = new JsonDeserializer();
              var p = d.Deserialize<PersonForJson>(doc.ToString());

              Assert.Equal(DateTime.Parse("01-10-2010 14:23:54"), p.StartDate);
        }
开发者ID:CSharpByDesign,项目名称:RestSharp,代码行数:10,代码来源:JsonTests.cs

示例5: Can_Deserialize_4sq_Json_With_Root_Element_Specified

        public void Can_Deserialize_4sq_Json_With_Root_Element_Specified()
        {
            var doc = File.ReadAllText(Path.Combine("SampleData", "4sq.txt"));

            var json = new JsonDeserializer();
            json.RootElement = "response";

            var output = json.Deserialize<VenuesResponse>(new RestResponse { Content = doc });

            Assert.NotEmpty(output.Groups);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:11,代码来源:JsonTests.cs

示例6: Can_Deserialize_DateTime

        public void Can_Deserialize_DateTime()
        {
            var doc = File.ReadAllText(Path.Combine("SampleData", "datetimes.txt"));
            var d = new JsonDeserializer();
            var response = new RestResponse { Content = doc };
            var payload = d.Deserialize<DateTimeTestStructure>(response);

            Assert.Equal(
                new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc).ToString("u"),
                payload.DateTime.ToString("u"));
        }
开发者ID:jsclayton,项目名称:RestSharp,代码行数:11,代码来源:JsonTests.cs

示例7: Can_Deserialize_Elements_to_Nullable_Values

        public void Can_Deserialize_Elements_to_Nullable_Values()
        {
            var doc = CreateJsonWithoutEmptyValues();

            var json = new JsonDeserializer();
            var output = json.Deserialize<NullableValues>(new RestResponse { Content = doc });

            Assert.NotNull(output.Id);
            Assert.NotNull(output.StartDate);
            Assert.NotNull(output.UniqueId);

            Assert.Equal(123, output.Id);
            Assert.Equal(new DateTime(2010, 2, 21, 9, 35, 00), output.StartDate);
            Assert.Equal(new Guid(GuidString), output.UniqueId);
        }
开发者ID:nachojammers,项目名称:RestSharp,代码行数:15,代码来源:JsonTests.cs

示例8: Can_Deserialize_Custom_Formatted_Date

        public void Can_Deserialize_Custom_Formatted_Date()
        {
            var format = "dd yyyy MMM, hh:mm ss tt";
            var date = new DateTime(2010, 2, 8, 11, 11, 11);

            var formatted = new {
                StartDate = date.ToString(format)
            };

            var data = JsonConvert.SerializeObject(formatted);
            var response = new RestResponse { Content = data };

            var json = new JsonDeserializer { DateFormat = format };

            var output = json.Deserialize<PersonForJson>(response);

            Assert.Equal(date, output.StartDate);
        }
开发者ID:geoffreysimpson,项目名称:RestSharp,代码行数:18,代码来源:JsonTests.cs

示例9: Can_Deserialize_Names_With_Underscores_With_Default_Root

		public void Can_Deserialize_Names_With_Underscores_With_Default_Root() {
			var doc = CreateJsonWithUnderscores();
			var d = new JsonDeserializer();
			var p = d.Deserialize<PersonForJson>(doc);

			Assert.Equal("John Sheehan", p.Name);
			Assert.Equal(new DateTime(2009, 9, 25, 0, 6, 1), p.StartDate);
			Assert.Equal(28, p.Age);
			Assert.Equal(long.MaxValue, p.BigNumber);
			Assert.Equal(99.9999m, p.Percent);
			Assert.Equal(false, p.IsCool);

			Assert.NotNull(p.Friends);
			Assert.Equal(10, p.Friends.Count);

			Assert.NotNull(p.BestFriend);
			Assert.Equal("The Fonz", p.BestFriend.Name);
			Assert.Equal(1952, p.BestFriend.Since);

			Assert.NotEmpty(p.Foes);
			Assert.Equal("Foe 1", p.Foes["dict1"].Nickname);
			Assert.Equal("Foe 2", p.Foes["dict2"].Nickname);
		}
开发者ID:restsharp,项目名称:RestSharp,代码行数:23,代码来源:JsonTests.cs

示例10: Can_Deserialize_Simple_Generic_List_of_Simple_Types_With_Nulls

        public void Can_Deserialize_Simple_Generic_List_of_Simple_Types_With_Nulls()
        {
            const string content = "{\"users\":[\"johnsheehan\",\"jagregory\",null,\"drusellers\",\"structuremap\"]}";
            var json = new JsonDeserializer { RootElement = "users" };

            var output = json.Deserialize<List<string>> (new RestResponse { Content = content });

            Assert.NotEmpty (output);
            Assert.Equal (null, output[2]);
            Assert.Equal (5, output.Count);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:11,代码来源:JsonTests.cs

示例11: Can_Deserialize_Simple_Generic_List_Given_Toplevel_Item_Without_Array

        public void Can_Deserialize_Simple_Generic_List_Given_Toplevel_Item_Without_Array()
        {
            const string content = "\"johnsheehan\"";
            var json = new JsonDeserializer ();

            var output = json.Deserialize<List<string>> (new RestResponse { Content = content });

            Assert.True (output.SequenceEqual (new[] { "johnsheehan" }));
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:9,代码来源:JsonTests.cs

示例12: Can_Deserialize_Root_Json_Array_To_List

 public void Can_Deserialize_Root_Json_Array_To_List()
 {
     var data = File.ReadAllText(Path.Combine("SampleData", "jsonarray.txt"));
     var response = new RestResponse { Content = data };
     var json = new JsonDeserializer();
     var output = json.Deserialize<List<status>>(response);
     Assert.Equal(4, output.Count);
 }
开发者ID:t9mike,项目名称:RestSharp,代码行数:8,代码来源:JsonTests.cs

示例13: Can_Deserialize_Quoted_Primitive

        public void Can_Deserialize_Quoted_Primitive()
        {
            var doc = new JObject();
            doc["Age"] = "28";

            var d = new JsonDeserializer();
            var response = new RestResponse { Content = doc.ToString() };
            var p = d.Deserialize<PersonForJson>(response);

            Assert.Equal(28, p.Age);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:11,代码来源:JsonTests.cs

示例14: Can_Deserialize_Root_Json_Array_To_List

 public void Can_Deserialize_Root_Json_Array_To_List()
 {
     var data = File.ReadAllText(@"..\..\SampleData\jsonarray.txt");
     var json = new JsonDeserializer();
     var output = json.Deserialize<List<status>>(data);
     Assert.Equal(4, output.Count);
 }
开发者ID:CSharpByDesign,项目名称:RestSharp,代码行数:7,代码来源:JsonTests.cs

示例15: Can_Deserialize_Various_Enum_Values

        public void Can_Deserialize_Various_Enum_Values()
        {
            var data = File.ReadAllText (Path.Combine ("SampleData", "jsonenums.txt"));
            var response = new RestResponse { Content = data };
            var json = new JsonDeserializer ();
            var output = json.Deserialize<JsonEnumsTestStructure>(response);

            Assert.Equal (output.Upper, Disposition.Friendly);
            Assert.Equal (output.Lower, Disposition.Friendly);
            Assert.Equal (output.CamelCased, Disposition.SoSo);
            Assert.Equal (output.Underscores, Disposition.SoSo);
            Assert.Equal (output.LowerUnderscores, Disposition.SoSo);
            Assert.Equal (output.Dashes, Disposition.SoSo);
            Assert.Equal (output.LowerDashes, Disposition.SoSo);
        }
开发者ID:t9mike,项目名称:RestSharp,代码行数:15,代码来源:JsonTests.cs


注:本文中的Xunit.JsonDeserializer.Deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。