Browse Source

Merge pull request #262 from kysnm/property_must_be_separated_by_commas

Property must be separated by commas
pull/283/head
kallestenflo 8 years ago committed by GitHub
parent
commit
4dc0ca9b01
  1. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java
  2. 5
      json-path/src/test/java/com/jayway/jsonpath/PathCompilerTest.java

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

@ -576,6 +576,10 @@ public class PathCompiler {
break; break;
} else if (c == potentialStringDelimiter) { } else if (c == potentialStringDelimiter) {
if (inProperty && !inEscape) { if (inProperty && !inEscape) {
char nextSignificantChar = path.nextSignificantChar(readPosition);
if (nextSignificantChar != CLOSE_SQUARE_BRACKET && nextSignificantChar != COMMA) {
fail("Property must be separated by comma or Property must be terminated close square bracket at index "+readPosition);
}
endPosition = readPosition; endPosition = readPosition;
String prop = path.subSequence(startPosition, endPosition).toString(); String prop = path.subSequence(startPosition, endPosition).toString();
properties.add(Utils.unescape(prop)); properties.add(Utils.unescape(prop));

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

@ -266,4 +266,9 @@ public class PathCompilerTest {
public void accept_only_a_single_comma_between_indexes() { public void accept_only_a_single_comma_between_indexes() {
compile("$['1', ,'3']"); compile("$['1', ,'3']");
} }
@Test(expected = InvalidPathException.class)
public void property_must_be_separated_by_commas() {
compile("$['aaa'}'bbb']");
}
} }

Loading…
Cancel
Save