Browse Source

Fixed issue with string representation of function path.

pull/183/merge
Kalle Stenflo 9 years ago
parent
commit
e40161a778
  1. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java
  2. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/token/FunctionPathToken.java
  3. 5
      json-path/src/test/java/com/jayway/jsonpath/FilterCompilerTest.java

4
json-path/src/main/java/com/jayway/jsonpath/internal/filter/FilterCompiler.java

@ -298,7 +298,9 @@ public class FilterCompiler {
filter.setPosition(closingSquareBracketIndex + 1); filter.setPosition(closingSquareBracketIndex + 1);
} }
} }
boolean closingLogicalBracket = (filter.currentChar() == CLOSE_BRACKET && !currentCharIsClosingFunctionBracket(begin)); boolean closingFunctionBracket = (filter.currentChar() == CLOSE_BRACKET && currentCharIsClosingFunctionBracket(begin));
boolean closingLogicalBracket = (filter.currentChar() == CLOSE_BRACKET && !closingFunctionBracket);
if (!filter.inBounds() || isRelationalOperatorChar(filter.currentChar()) || filter.currentChar() == SPACE || closingLogicalBracket) { if (!filter.inBounds() || isRelationalOperatorChar(filter.currentChar()) || filter.currentChar() == SPACE || closingLogicalBracket) {
break; break;
} else { } else {

4
json-path/src/main/java/com/jayway/jsonpath/internal/token/FunctionPathToken.java

@ -51,6 +51,8 @@ public class FunctionPathToken extends PathToken {
@Override @Override
public String getPathFragment() { public String getPathFragment() {
return pathFragment; return "." + pathFragment;
} }
} }

5
json-path/src/test/java/com/jayway/jsonpath/FilterCompilerTest.java

@ -36,6 +36,9 @@ public class FilterCompilerTest {
assertThat(compile("[?(@.a IN {'foo':'bar'})]").toString()).isEqualTo("[?(@['a'] IN {'foo':'bar'})]"); assertThat(compile("[?(@.a IN {'foo':'bar'})]").toString()).isEqualTo("[?(@['a'] IN {'foo':'bar'})]");
assertThat(compile("[?(@.value<'7')]").toString()).isEqualTo("[?(@['value'] < '7')]"); assertThat(compile("[?(@.value<'7')]").toString()).isEqualTo("[?(@['value'] < '7')]");
assertThat(compile("[?(@.message == 'it\\\\')]").toString()).isEqualTo("[?(@['message'] == 'it\\\\')]"); assertThat(compile("[?(@.message == 'it\\\\')]").toString()).isEqualTo("[?(@['message'] == 'it\\\\')]");
assertThat(compile("[?(@.message.%min() > 10)]").toString()).isEqualTo("[?(@['message'].%min() > 10)]");
assertThat(compile("[?(@.message.%min()==10)]").toString()).isEqualTo("[?(@['message'].%min() == 10)]");
assertThat(compile("[?(10 == @.message.%min())]").toString()).isEqualTo("[?(10 == @['message'].%min())]");
assertThat(compile("[?(((@)))]").toString()).isEqualTo("[?(@)]");
} }
} }

Loading…
Cancel
Save