|
1 | 1 | package com.jayway.jsonpath.internal.path;
|
2 | 2 |
|
| 3 | +import com.jayway.jsonpath.internal.Path; |
3 | 4 | import com.jayway.jsonpath.internal.PathRef;
|
4 | 5 | import com.jayway.jsonpath.internal.function.Parameter;
|
5 | 6 | import com.jayway.jsonpath.internal.function.PathFunction;
|
@@ -39,11 +40,29 @@ public void evaluate(String currentPath, PathRef parent, Object model, Evaluatio
|
39 | 40 | evaluateParameters(currentPath, parent, model, ctx);
|
40 | 41 | Object result = pathFunction.invoke(currentPath, parent, model, ctx, functionParams);
|
41 | 42 | ctx.addResult(currentPath + "." + functionName, parent, result);
|
| 43 | + cleanWildcardPathToken(); |
42 | 44 | if (!isLeaf()) {
|
43 | 45 | next().evaluate(currentPath, parent, result, ctx);
|
44 | 46 | }
|
45 | 47 | }
|
46 | 48 |
|
| 49 | + private void cleanWildcardPathToken() { |
| 50 | + if (null != functionParams && functionParams.size() > 0) { |
| 51 | + Path path = functionParams.get(0).getPath(); |
| 52 | + if (null != path && !path.isFunctionPath() && path instanceof CompiledPath) { |
| 53 | + RootPathToken root = ((CompiledPath) path).getRoot(); |
| 54 | + PathToken tail = root.getNext(); |
| 55 | + while (null != tail && null != tail.getNext() ) { |
| 56 | + if(tail.getNext() instanceof WildcardPathToken){ |
| 57 | + tail.setNext(tail.getNext().getNext()); |
| 58 | + break; |
| 59 | + } |
| 60 | + tail = tail.getNext(); |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + |
47 | 66 | private void evaluateParameters(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
|
48 | 67 |
|
49 | 68 | if (null != functionParams) {
|
|
0 commit comments