I am using JSON simple to parse a JSON file. When I do so I get a JSONArray. But when I try to iterate through it and get its JSONObject elements I get an error.
This is my code:
JSONArray jsonData = (JSONArray) jsonParser.parse(reader);
List<JSONObject> elementsList = new ArrayList<JSONObject>();
for (int i = 1; i < jsonData.size(); i++) {
elementsList.addAll(jsonData.get(i)); // Here jsonData.get(i) is a JSONObject
}
I get the following errors in Eclipse:
- The method addAll(Collection) in the type List is not applicable for the arguments (Object)
- Type safety: Unchecked cast from Object to Collection
Not sure what these mean and how to fix that.
JSONArray#get(int)?addAllin fact.jsonData.get(i)is aJSONObject