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); });
|
() => { 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]
|
[Test]
|
||||||
public void EvaluateMissingPropertyIndexWithError()
|
public void EvaluateMissingPropertyIndexWithError()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
|
|||||||
|
|
||||||
if (v != null)
|
if (v != null)
|
||||||
yield return v;
|
yield return v;
|
||||||
|
else if (errorWhenNoMatch)
|
||||||
if (errorWhenNoMatch)
|
|
||||||
throw new JsonException("Property '{0}' does not exist on JObject.".FormatWith(CultureInfo.InvariantCulture, Name));
|
throw new JsonException("Property '{0}' does not exist on JObject.".FormatWith(CultureInfo.InvariantCulture, Name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user