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,Object> obj=new JSONObject<String,Object>();
EDIT
Using Iterator<String> keys = obj.keys();
I'm getting a type safety warning:
Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator<String>
Also using Eclipse Infer generics doesn't execute any code changes