我有以下使用 org.json.simple 创建 JSON 对象的函数。
public JSONObject createJSONRequest() {
// /* Create JSON Objects */
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;
}
但是,当我使用 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");
我试图使用泛型类型。HashMap 使用泛型,但其他对象JSONObject
JSONArray
不使用。
非常感谢您的任何建议,