Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamesNK <james@newtonking.com>2011-10-01 09:37:08 +0400
committerJamesNK <james@newtonking.com>2011-10-01 09:37:08 +0400
commit14b8661c9234a23dc0cb4e251f52e028347308df (patch)
treed6291b6156e76df70ebde64454170c32403af70a
parent3baf856f921192904b2d931bd10f515bd91bec7e (diff)
-Changed JToken.Children to return an empty iterator rather than erroring
-rw-r--r--Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs2
-rw-r--r--Src/Newtonsoft.Json/Linq/JToken.cs2
2 files changed, 2 insertions, 2 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs
index 94673a2..df117f8 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs
@@ -148,11 +148,11 @@ namespace Newtonsoft.Json.Tests.Linq
}
[Test]
- [ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Cannot access child value on Newtonsoft.Json.Linq.JValue.")]
public void Children()
{
JValue v = new JValue(true);
var c = v.Children();
+ Assert.AreEqual(JEnumerable<JToken>.Empty, c);
}
[Test]
diff --git a/Src/Newtonsoft.Json/Linq/JToken.cs b/Src/Newtonsoft.Json/Linq/JToken.cs
index 600dbe3..6d74db1 100644
--- a/Src/Newtonsoft.Json/Linq/JToken.cs
+++ b/Src/Newtonsoft.Json/Linq/JToken.cs
@@ -265,7 +265,7 @@ namespace Newtonsoft.Json.Linq
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="JToken"/> containing the child tokens of this <see cref="JToken"/>, in document order.</returns>
public virtual JEnumerable<JToken> Children()
{
- throw new InvalidOperationException("Cannot access child value on {0}.".FormatWith(CultureInfo.InvariantCulture, GetType()));
+ return JEnumerable<JToken>.Empty;
}
/// <summary>