Merge pull request #224 from sgnr/master
Fix a bug where certain JSON path expressions would spuriously fail.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user