當前位置: 首頁>>代碼示例>>C#>>正文


C# JArray.SelectToken方法代碼示例

本文整理匯總了C#中Newtonsoft.Json.Linq.JArray.SelectToken方法的典型用法代碼示例。如果您正苦於以下問題:C# JArray.SelectToken方法的具體用法?C# JArray.SelectToken怎麽用?C# JArray.SelectToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Newtonsoft.Json.Linq.JArray的用法示例。


在下文中一共展示了JArray.SelectToken方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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:Top-Cat,項目名稱:SteamBot,代碼行數:11,代碼來源:JPathTests.cs

示例2: 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:Top-Cat,項目名稱:SteamBot,代碼行數:9,代碼來源:JPathTests.cs

示例3: 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:Top-Cat,項目名稱:SteamBot,代碼行數:11,代碼來源:JPathTests.cs

示例4: EvaluateOutOfBoundsIndxer

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

      JToken t = a.SelectToken("[1000].Ha");
      Assert.IsNull(t);
    }
開發者ID:Top-Cat,項目名稱:SteamBot,代碼行數:7,代碼來源:JPathTests.cs

示例5: EvaluateArraySliceWithError

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

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

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

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

            a = new JArray();

            ExceptionAssert.Throws<JsonException>(() => { a.SelectToken("[:]", true); }, "Array slice of * to * returned no results.");
        }
開發者ID:iwandi,項目名稱:Unity.Newtonsoft.Json,代碼行數:14,代碼來源:JPathExecuteTests.cs

示例6: EvaluatePropertyOnArray

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

      JToken t = a.SelectToken("BlahBlah");
      Assert.IsNull(t);
    }
開發者ID:Top-Cat,項目名稱:SteamBot,代碼行數:7,代碼來源:JPathTests.cs

示例7: EvaluateMultiPropertyIndexOnArrayWithError

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

            ExceptionAssert.Throws<JsonException>(() => { a.SelectToken("['Missing','Missing2']", true); }, "Properties 'Missing', 'Missing2' not valid on JArray.");
        }
開發者ID:iwandi,項目名稱:Unity.Newtonsoft.Json,代碼行數:6,代碼來源:JPathExecuteTests.cs

示例8: EvaluateNoResultsWithMultipleArrayIndexes

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

            ExceptionAssert.Throws<JsonException>(() => { a.SelectToken("[9,10]", true); }, @"Index 9 outside the bounds of JArray.");
        }
開發者ID:iwandi,項目名稱:Unity.Newtonsoft.Json,代碼行數:6,代碼來源:JPathExecuteTests.cs

示例9: EvaluateMultipleResultsError

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

            ExceptionAssert.Throws<JsonException>(() => { a.SelectToken("[0, 1]"); }, @"Path returned multiple tokens.");
        }
開發者ID:iwandi,項目名稱:Unity.Newtonsoft.Json,代碼行數:6,代碼來源:JPathExecuteTests.cs

示例10: EvaluateArrayOutOfBoundsIndxerWithError

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

      a.SelectToken("[1000].Ha", true);
    }
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:6,代碼來源:JPathTests.cs

示例11: EvaluatePropertyOnArrayWithError

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

      a.SelectToken("BlahBlah", true);
    }
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:6,代碼來源:JPathTests.cs


注:本文中的Newtonsoft.Json.Linq.JArray.SelectToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。