0

Am new to java .getJSONValue method returns a array like this [men,women] and [dog,cat] while executing the above code am getting:

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Map

  private Map<String, List<String>> devcap = new HashMap <String, List<String>>();
     public <T>T getJSONValue(Response res, String path ){
           String json = res.asString();
           JsonPath jpath = new JsonPath(json);
           return jpath.get(path);
     }



     devcap = helper.getJSONValue(response, "results.devices.cap");
     try {    
       for (Map.Entry<String, List<String>> entry : devcap.entrySet()) {
            String key = entry.getKey();
            List<String> values = entry.getValue();
            System.out.println("Key = " + key);
            System.out.println("Values = " + values + "n");
       }

How to get rid of this error

Dyrandz Famador
  • 4,499
  • 5
  • 25
  • 40
saathu
  • 59
  • 1
  • 3
  • 13

0 Answers0