I am getting json response in a request like Response=
[
{
"id":"1",
"name":"Elfred",
"city":"mexico",
"@type":"author"
},
{
"id":"2",
"name":"michael",
"city":"San Fransico",
"@type":"Editor"}
]
I aM USING jsr223 Assertion I wanted to check my json Response contains keys : groovy Code:
import groovy.json.JsonSlurper;
import java.util.*;
def failureMessage = "";
def jsonResponse = null;
JsonSlurper JSON = new JsonSlurper ();
jsonResponse = JSON.parseText(prev.getResponseDataAsString());
if (!jsonResponse.keySet().containsAll("id","name","city","@type")) {
failureMessage += "The json config element has wrong structure.\n\n";
}
I am getting Exception as
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.keySet() is applicable for argument types: () values: []
Possible solutions: toSet(), toSet(), set(int, java.lang.Object), set(int, java.lang.Object), get(int), get(int)
What am i missing ??