Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic of parsing function with no arguments. #990

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ else if (path.charAt(i) == OPEN_PARENTHESIS)
String functionName = path.subSequence(startPosition, endPosition).toString();
functionParameters = parseFunctionParameters(functionName);
} else {
path.setPosition(readPosition + 1);
path.setPosition(readPosition + 2);
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,11 @@ public void accept_only_a_single_comma_between_indexes() {
public void property_must_be_separated_by_commas() {
assertThrows(InvalidPathException.class, () -> compile("$['aaa'}'bbb']"));
}

@Test
public void function_with_no_argument_can_be_parsed() {
String json = "{\"empty\": [], \"number-series\" : [[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12]]}";
Integer result = JsonPath.read(json, "$.number-series.first().last()");
assertThat(result).isEqualTo(10);
}
}