Skip to content

Conversation

@zline
Copy link
Contributor

@zline zline commented Dec 23, 2015

The first fix is for test
assertThat(compile("[?((@.a && @.b || @.c) || @.x)]").toString()).isEqualTo("[?(((@['a'] && @['b']) || @['c']) || @['x'])]");
The thing is logical OR should has lower priority than logical AND. It seemed entire top-level filter parsing (FilterCompiler.compile) was not aware of priorities. So it was reimplemented 'by hand' using backtracking and the following grammar:

LogicalOR               = LogicalAND { '||' LogicalAND }
LogicalAND              = LogicalANDOperand { '&&' LogicalANDOperand }
LogicalANDOperand       = RelationalExpression | '(' LogicalOR ')'
RelationalExpression    = Value [ RelationalOperator Value ]

The second fix is for issue #175 . I've added if to SizeEvaluator, but also a catch block in PredicatePathToken.accept so that problem with criteria evaluation for one array element would't prematurely stop filtering routine.

kallestenflo added a commit that referenced this pull request Dec 29, 2015
Fix for logical operator priorities and issue #175
@kallestenflo kallestenflo merged commit 3c5f57f into json-path:master Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants