Browse Source

Merge pull request #448 from davsclaus/pos-fix

Fixes #447: To report correct index of invalid jsonpath failure. This…
pull/517/head
kallestenflo 6 years ago committed by GitHub
parent
commit
b13740e491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java

3
json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java

@ -484,7 +484,8 @@ public class PathCompiler {
if (inBracket) { if (inBracket) {
int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD); int wildCardIndex = path.indexOfNextSignificantChar(WILDCARD);
if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) { if (!path.nextSignificantCharIs(wildCardIndex, CLOSE_SQUARE_BRACKET)) {
throw new InvalidPathException("Expected wildcard token to end with ']' on position " + wildCardIndex + 1); int offset = wildCardIndex + 1;
throw new InvalidPathException("Expected wildcard token to end with ']' on position " + offset);
} }
int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET); int bracketCloseIndex = path.indexOfNextSignificantChar(wildCardIndex, CLOSE_SQUARE_BRACKET);
path.setPosition(bracketCloseIndex + 1); path.setPosition(bracketCloseIndex + 1);

Loading…
Cancel
Save