Java 未选中将(E)添加为原始类型ArrayList和HashMap的成员的调用

Java 未选中将(E)添加为原始类型ArrayList和HashMap的成员的调用,java,json-simple,Java,Json Simple,我有以下函数,它使用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_TOKE

我有以下函数,它使用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;
}
我尝试使用泛型类型。HashMap使用泛型,但其他对象
JSONObject
JSONArray
不使用


非常感谢您的建议,

您将收到此警告,因为库在内部使用原始类型集合。 要隐藏此警告,请使用
@SuppressWarnings(“未选中”)
注释方法


如果您想使用支持泛型的json库。你可以试试看。我自己也在很多项目中使用过它。这很简单,并且使用通用集合。

JSONArray、JSONObject在哪里?猜测:请参见和(这意味着您无法避免这些警告,除非通过抑制它们…)@Marco13谢谢如果写的是JSONE简单的库(假设我是),那么你可以考虑添加<代码> JSON Simult标签(我可以把评论变成答案…)所以答案“永远不要使用代码> COM.GooGoCord.JSON简单< /COD>”因为谁将注释代码中的所有内容?
[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");