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


C# JArray.SelectToken方法代码示例

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


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

示例1: EvaluateArray

    public void EvaluateArray()
    {
      JArray a = new JArray(1, 2, 3, 4);

      JToken t = a.SelectToken("[1]");
      Assert.IsNotNull(t);
      Assert.AreEqual(JTokenType.Integer, t.Type);
      Assert.AreEqual(2, (int)t);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:9,代码来源:JPathTests.cs

示例2: EvaluateOutOfBoundsIndxer

    public void EvaluateOutOfBoundsIndxer()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      JToken t = a.SelectToken("[1000].Ha");
      Assert.IsNull(t);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:7,代码来源:JPathTests.cs

示例3: EvaluateOutOfBoundsIndxerWithError

    public void EvaluateOutOfBoundsIndxerWithError()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      a.SelectToken("[1000].Ha", true);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:6,代码来源:JPathTests.cs

示例4: EvaluatePropertyOnArray

    public void EvaluatePropertyOnArray()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      JToken t = a.SelectToken("BlahBlah");
      Assert.IsNull(t);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:7,代码来源:JPathTests.cs

示例5: EvaluatePropertyOnArrayWithError

    public void EvaluatePropertyOnArrayWithError()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      a.SelectToken("BlahBlah", true);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:6,代码来源:JPathTests.cs

示例6: EvaluatePropertyOnArrayWithError

    public void EvaluatePropertyOnArrayWithError()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      ExceptionAssert.Throws<JsonException>(
        @"Property 'BlahBlah' not valid on JArray.",
        () =>
        {
          a.SelectToken("BlahBlah", true);
        });
    }
开发者ID:royra,项目名称:ravendb,代码行数:11,代码来源:JPathTests.cs

示例7: EvaluateArrayOutOfBoundsIndxerWithError

    public void EvaluateArrayOutOfBoundsIndxerWithError()
    {
      JArray a = new JArray(1, 2, 3, 4, 5);

      ExceptionAssert.Throws<IndexOutOfRangeException>(
        "Index 1000 outside the bounds of JArray.",
        () =>
        {
          a.SelectToken("[1000].Ha", true);
        });
    }
开发者ID:royra,项目名称:ravendb,代码行数:11,代码来源:JPathTests.cs

示例8: EvaluateArrayOutOfBoundsIndxerWithError

        public void EvaluateArrayOutOfBoundsIndxerWithError()
        {
            JArray a = new JArray(1, 2, 3, 4, 5);

            AssertException.Throws<JsonException>(() => { a.SelectToken("[1000].Ha", true); }, "Index 1000 outside the bounds of JArray.");
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:6,代码来源:JPathExecuteTests.cs

示例9: EvaluateArraySliceWithError

        public void EvaluateArraySliceWithError()
        {
            JArray a = new JArray(1, 2, 3, 4, 5);

            AssertException.Throws<JsonException>(() => { a.SelectToken("[99:]", true); }, "Array slice of 99 to * returned no results.");

            AssertException.Throws<JsonException>(() => { a.SelectToken("[1:-19]", true); }, "Array slice of 1 to -19 returned no results.");

            AssertException.Throws<JsonException>(() => { a.SelectToken("[:-19]", true); }, "Array slice of * to -19 returned no results.");

            a = new JArray();

            AssertException.Throws<JsonException>(() => { a.SelectToken("[:]", true); }, "Array slice of * to * returned no results.");
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:14,代码来源:JPathExecuteTests.cs

示例10: EvaluateMultiPropertyIndexOnArrayWithError

        public void EvaluateMultiPropertyIndexOnArrayWithError()
        {
            JArray a = new JArray(1, 2, 3, 4, 5);

            AssertException.Throws<JsonException>(() => { a.SelectToken("['Missing','Missing2']", true); }, "Properties 'Missing', 'Missing2' not valid on JArray.");
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:6,代码来源:JPathExecuteTests.cs

示例11: EvaluateNoResultsWithMultipleArrayIndexes

        public void EvaluateNoResultsWithMultipleArrayIndexes()
        {
            JArray a = new JArray(1, 2, 3, 4, 5);

            AssertException.Throws<JsonException>(() => { a.SelectToken("[9,10]", true); }, @"Index 9 outside the bounds of JArray.");
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:6,代码来源:JPathExecuteTests.cs

示例12: EvaluateMultipleResultsError

        public void EvaluateMultipleResultsError()
        {
            JArray a = new JArray(1, 2, 3, 4, 5);

            AssertException.Throws<JsonException>(() => { a.SelectToken("[0, 1]"); }, @"Path returned multiple tokens.");
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:6,代码来源:JPathExecuteTests.cs


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