|
|
|
@ -5,9 +5,7 @@ import com.jayway.jsonpath.internal.EvaluationContext;
|
|
|
|
|
import com.jayway.jsonpath.internal.PathRef; |
|
|
|
|
import net.minidev.json.JSONArray; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Provides the length of a JSONArray Object |
|
|
|
@ -18,9 +16,8 @@ public class Length implements Function {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx) { |
|
|
|
|
if (model instanceof JSONArray) { |
|
|
|
|
JSONArray array = (JSONArray)model; |
|
|
|
|
return Integer.valueOf(array.size()); |
|
|
|
|
if (model instanceof Collection) { |
|
|
|
|
return Integer.valueOf(((Collection) model).size()); |
|
|
|
|
} |
|
|
|
|
else if (model instanceof Map) { |
|
|
|
|
return Integer.valueOf(((Map) model).size()); |
|
|
|
|