I have a code to parse a huge JSON:
static <T> List<T> parseJSON(String json) {
Map<String, T> result = jsonSlurper.parseText(json)
List<T> list = result.result
return list
}
the String json = {result:[{obj1},{obj2}....]}
I am getting a proper List at the end with the variable list but in Java when I get the value it throws an exception java.lang.ClassCastException: groovy.json.internal.LazyMap cannot be cast to {MyPOJO}
here is how I receive the data
List<MYClass> list = MyClass.parseJSON(someString);
for(MyClass i : list) {
System.out.println(i.someValue());
}
how can I resolve this?