Browse Source

Merge pull request #5 from mattbishop/master

Bug fix for IndexOutOfBoundsException
pull/6/head
kallestenflo 13 years ago
parent
commit
b7595b7ca0
  1. 2
      json-path/src/main/java/com/jayway/jsonpath/reader/PathTokenizer.java
  2. 7
      json-path/src/test/java/com/jayway/jsonpath/SplitPathFragmentsTest.java

2
json-path/src/main/java/com/jayway/jsonpath/reader/PathTokenizer.java

@ -84,7 +84,7 @@ public class PathTokenizer implements Iterable<PathToken> {
case '.': case '.':
poll(); poll();
if (peek() == '.') { if (!isEmpty() && peek() == '.') {
poll(); poll();
fragments.add(".."); fragments.add("..");

7
json-path/src/test/java/com/jayway/jsonpath/SplitPathFragmentsTest.java

@ -78,6 +78,13 @@ public class SplitPathFragmentsTest {
assertPath("$..book[ ?(@.price<10)]", hasItems("$", "..", "book", "[?(@.price<10)]")); assertPath("$..book[ ?(@.price<10)]", hasItems("$", "..", "book", "[?(@.price<10)]"));
} }
@Test
public void dot_ending_ignored() throws Exception {
assertPath("$..book['something'].", hasItems("$", "..", "something"));
}
@Test @Test
public void invalid_path_throws_exception() throws Exception { public void invalid_path_throws_exception() throws Exception {
assertPathInvalid("$...*"); assertPathInvalid("$...*");

Loading…
Cancel
Save