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


C# TestObjects.PersonRaw类代码示例

本文整理汇总了C#中Newtonsoft.Json.Tests.TestObjects.PersonRaw的典型用法代码示例。如果您正苦于以下问题:C# PersonRaw类的具体用法?C# PersonRaw怎么用?C# PersonRaw使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PersonRaw类属于Newtonsoft.Json.Tests.TestObjects命名空间,在下文中一共展示了PersonRaw类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeserializeFromRaw

        public void DeserializeFromRaw()
        {
            PersonRaw raw = new PersonRaw
              {
            FirstName = "FirstNameValue",
            RawContent = new JRaw("[1,2,3,4,5]"),
            LastName = "LastNameValue"
              };

              JObject o = JObject.FromObject(raw);

              JsonReader reader = new JTokenReader(o);
              JsonSerializer serializer = new JsonSerializer();
              raw = (PersonRaw)serializer.Deserialize(reader, typeof(PersonRaw));

              Assert.AreEqual("FirstNameValue", raw.FirstName);
              Assert.AreEqual("LastNameValue", raw.LastName);
              Assert.AreEqual("[1,2,3,4,5]", raw.RawContent.Value);
        }
开发者ID:adbre,项目名称:jsoncf,代码行数:19,代码来源:JObjectTests.cs

示例2: JTokenReader

    public void JTokenReader()
    {
      PersonRaw raw = new PersonRaw
      {
        FirstName = "FirstNameValue",
        RawContent = new JRaw("[1,2,3,4,5]"),
        LastName = "LastNameValue"
      };

      JObject o = JObject.FromObject(raw);

      JsonReader reader = new JTokenReader(o);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.Raw, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

      Assert.IsFalse(reader.Read());
    }
开发者ID:Jessecar96,项目名称:Newtonsoft.Json,代码行数:39,代码来源:JObjectTests.cs

示例3: FromObjectRaw

    public void FromObjectRaw()
    {
      PersonRaw raw = new PersonRaw
      {
        FirstName = "FirstNameValue",
        RawContent = new JRaw("[1,2,3,4,5]"),
        LastName = "LastNameValue"
      };

      JObject o = JObject.FromObject(raw);

      Assert.AreEqual("FirstNameValue", (string)o["first_name"]);
      Assert.AreEqual(JTokenType.Raw, ((JValue)o["RawContent"]).Type);
      Assert.AreEqual("[1,2,3,4,5]", (string)o["RawContent"]);
      Assert.AreEqual("LastNameValue", (string)o["last_name"]);
    }
开发者ID:Jessecar96,项目名称:Newtonsoft.Json,代码行数:16,代码来源:JObjectTests.cs


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