I'm trying to read a JSON, and store its value in dataVO. This dataVO includes ArrayList.
CODE:
if (jsonObject.get(fld.getName()) != null) {
if (fld.getType() == Integer.class) {
methList[i].invoke(mvo, Integer.parseInt(jsonObject.get(fldName).toString()));
} else if (fld.getType() == String.class) {
methList[i].invoke(mvo, jsonObject.get(fldName).toString());
} else if (fld.getType() == Long.class) {
methList[i].invoke(mvo, Long.valueOf(jsonObject.get(fldName).toString()));
} else if (fld.getType() == ArrayList.class) {
/* HERE!! */
}else {
methList[i].invoke(mvo, jsonObject.get(fldName).toString());
}
}
I do not know how to use methList[i].invoke in /* HERE!! */.
If I use
methList[i].invoke(mvo, jsonObject.get(fldName));
or
methList[i].invoke(mvo, (ArrayList) jsonObject.get(fldName));
An error occured.
ERROR:
org.json.JSONObject$1 cannot be cast to java.util.ArrayList
How can I fix this error?