'Correct way to parameterized JSONArray method add
I'm trying to generate a JSON using a LinkedHashMap<String, Object> Object for data and a JSON Array Object to generate the JSON string like this:
JSONArray json = new JSONArray();
LinkedHashMap<String, Object> data = new LinkedHashMap<String, Object>();
data.put("SomeKey",Object);
json.add(data);//Here jumps up the warning: (Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized)
/* More Code */
return json.toString();
I've tried to get parameterized data adding the next code:
json.add((LinkedHashMap<String,Object>)data);
but warning remains.
How can I rid of this warning in a good way? Or there's some better way to do it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
