Browse Source

feat: Fix multiple nested calls

pull/1011/head
Gio Gutierrez 11 months ago
parent
commit
50d1773f77
  1. 6
      json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java
  2. 8
      json-path/src/test/java/com/jayway/jsonpath/internal/function/NestedFunctionTest.java

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

@ -349,15 +349,11 @@ public class PathCompiler {
// we've encountered a COMMA do the same
case CLOSE_PARENTHESIS:
groupParen--;
//CS304 Issue link: https://github.com/json-path/JsonPath/issues/620
if (0 > groupParen || priorChar == '(') {
parameter.append(c);
}
case COMMA:
// In this state we've reach the end of a function parameter and we can pass along the parameter string
// to the parser
if ((0 == groupQuote && 0 == groupBrace && 0 == groupBracket
&& ((0 == groupParen && CLOSE_PARENTHESIS == c) || 1 == groupParen))) {
&& ((0 == groupParen && CLOSE_PARENTHESIS == c) || (1 == groupParen && c == COMMA)))) {
endOfStream = (0 == groupParen);
if (null != type) {

8
json-path/src/test/java/com/jayway/jsonpath/internal/function/NestedFunctionTest.java

@ -73,6 +73,14 @@ public class NestedFunctionTest extends BaseFunctionTest {
}
@ParameterizedTest
@MethodSource("configurations")
public void testMultipleCall(Configuration conf) {
verifyTextFunction(conf, "$.concat($.text[0], $.concat( $.concat($.text[3], \"-1\"), $.concat($.text[4], \"-1\")))", "ad-1e-1");
}
@ParameterizedTest
@MethodSource("configurations")
public void testStringAndNumberConcat(Configuration conf) {

Loading…
Cancel
Save