Fix a bug where certain JSON path expressions would spuriously fail.

This commit is contained in:
Simon Génier
2014-03-11 16:10:21 -04:00
parent d684913966
commit 28062b9cbb
2 changed files with 11 additions and 2 deletions
@@ -272,6 +272,16 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
() => { o.SelectToken("Missing", true); });
}
[Test]
public void EvaluatePropertyWithoutError()
{
JObject o = new JObject(
new JProperty("Blah", 1));
JValue v = (JValue)o.SelectToken("Blah", true);
Assert.AreEqual(1L, v.Value);
}
[Test]
public void EvaluateMissingPropertyIndexWithError()
{
@@ -21,8 +21,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
if (v != null)
yield return v;
if (errorWhenNoMatch)
else if (errorWhenNoMatch)
throw new JsonException("Property '{0}' does not exist on JObject.".FormatWith(CultureInfo.InvariantCulture, Name));
}
else