Browse Source

Property must be separated by commas

pull/262/head
kysnm 8 years ago
parent
commit
2572cbab02
  1. 3
      json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java
  2. 5
      json-path/src/test/java/com/jayway/jsonpath/PathCompilerTest.java

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

@ -576,6 +576,9 @@ public class PathCompiler {
break; break;
} else if (c == potentialStringDelimiter) { } else if (c == potentialStringDelimiter) {
if (inProperty && !inEscape) { if (inProperty && !inEscape) {
if (!path.nextSignificantCharIs(readPosition, COMMA) && !path.nextSignificantCharIs(readPosition, CLOSE_SQUARE_BRACKET)) {
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