-Fixed JSONPath recursive descent queries

This commit is contained in:
James Newton-King
2017-04-26 11:09:15 +12:00
parent c80be730f8
commit b3d514b617
7 changed files with 232 additions and 46 deletions
@@ -202,6 +202,29 @@ namespace Newtonsoft.Json.Tests.Linq.JsonPath
Assert.AreEqual("Blah", ((ScanFilter)path.Filters[0]).Name);
}
[Test]
public void QueryTrue()
{
JPath path = new JPath("$.elements[?(true)]");
Assert.AreEqual(2, path.Filters.Count);
Assert.AreEqual("elements", ((FieldFilter)path.Filters[0]).Name);
Assert.AreEqual(QueryOperator.Exists, ((QueryFilter)path.Filters[1]).Expression.Operator);
}
[Test]
public void ScanQuery()
{
JPath path = new JPath("$.elements..[?(@.id=='AAA')]");
Assert.AreEqual(2, path.Filters.Count);
Assert.AreEqual("elements", ((FieldFilter)path.Filters[0]).Name);
BooleanQueryExpression expression = (BooleanQueryExpression)((QueryScanFilter) path.Filters[1]).Expression;
List<PathFilter> paths = (List<PathFilter>)expression.Left;
Assert.IsInstanceOf(typeof(FieldFilter), paths[0]);
}
[Test]
public void WildcardScanWithRoot()
{