Generify JSONObject string keys
问题 I have existing code which use org.json.JSONObject 's Iterator JSONObject obj = new JSONObject(); obj.put("key1", "value1"); obj.put("key2", "value2"); Iterator keys = obj.keys(); ... With compile warning Iterator is a raw type. References to generic type Iterator<E> should be parameterized I can update to generic version: Iterator<?> keys = obj.keys(); But isn't there a way to "generify" JSONObject with String keys? I find this answer but its suggestion doesn't compiled JSONObject<String