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