Browse Source
Example: $.sum({$.numbers.min()}, {$.numbers.max()}) You could also do something such as: $.numbers.add({$.numbers.min()}) where add for each element in the array took another JsonPath parameter that we'd add to resulting in an array result with the min value of numbers added to each element in the number's array. Obviously there's better examples than the above - but these changes allow the PathCompiler to parse the function parameters for nested JsonPath'spull/167/head
Matthew J Greenwood
9 years ago
5 changed files with 119 additions and 10 deletions
@ -0,0 +1,34 @@ |
|||||||
|
package com.jayway.jsonpath.internal.function; |
||||||
|
|
||||||
|
import com.jayway.jsonpath.Configuration; |
||||||
|
import com.jayway.jsonpath.Configurations; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.junit.runners.Parameterized; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by matt@mjgreenwood.net on 12/10/15. |
||||||
|
*/ |
||||||
|
@RunWith(Parameterized.class) |
||||||
|
public class NestedFunctionTest extends BaseFunctionTest { |
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NumericPathFunctionTest.class); |
||||||
|
|
||||||
|
private Configuration conf = Configurations.GSON_CONFIGURATION; |
||||||
|
|
||||||
|
public NestedFunctionTest(Configuration conf) { |
||||||
|
logger.debug("Testing with configuration {}", conf.getClass().getName()); |
||||||
|
this.conf = conf; |
||||||
|
} |
||||||
|
|
||||||
|
@Parameterized.Parameters |
||||||
|
public static Iterable<Configuration> configurations() { |
||||||
|
return Configurations.configurations(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testAverageOfDoubles() { |
||||||
|
verifyMathFunction(conf, "$.sum({$.numbers.min()}, {$.numbers.max()})", 5.5); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue