diff options
author | JamesNK <james@newtonking.com> | 2011-10-01 09:37:08 +0400 |
---|---|---|
committer | JamesNK <james@newtonking.com> | 2011-10-01 09:37:08 +0400 |
commit | 14b8661c9234a23dc0cb4e251f52e028347308df (patch) | |
tree | d6291b6156e76df70ebde64454170c32403af70a | |
parent | 3baf856f921192904b2d931bd10f515bd91bec7e (diff) |
-Changed JToken.Children to return an empty iterator rather than erroring
-rw-r--r-- | Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs | 2 | ||||
-rw-r--r-- | Src/Newtonsoft.Json/Linq/JToken.cs | 2 |
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>
|