I have the following function that uses org.json.simple to create a JSON object.
public JSONObject createJSONRequest() {
JSONObject jsonObject = new JSONObject();
Map<String, String> map = new HashMap<String, String>();
map.put(ACCESS_TOKEN_KEY, mAccessToken);
map.put(SESSION_ID_KEY, mSessionId);
map.put(SNAPZ_ID_KEY, mSnapzId);
map.put(EMAIL_KEY, mEmail);
map.put(EMAIL_PWD_KEY, mEmailPwd);
JSONArray list = new JSONArray();
list.add(map);
jsonObject.put("parameters", list);
jsonObject.put("function", "verifyEmail");
return jsonObject;
}
However, I continue to receive this warning when I use the lint checker.
[unchecked] unchecked call to add(E) as a member of the raw type ArrayList
list.add(map);
^
where E is a type-variable: E extends Object declared in class ArrayList
warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap
jsonObject.put("parameters", list);
^
where K,V are type-variables:
K extends Object declared in class HashMap
V extends Object declared in class HashMap
warning: [unchecked] unchecked call to put(K,V) as a member of the raw type HashMap
jsonObject.put("function", "verifyEmail");
I tried to use a generic type. HashMap uses generics, but other objects JSONObject JSONArraydo not work.
Thanks so much for any suggestions,
source
share