My problem comes from getting an Iterator from a JSONObject.
Code generating error in its simplest form:
String json = client.retrieveList(); JSONObject jsonList = new JSONObject(json); Iterator<String> i = jsonList.keys(); while(i.hasNext()) { String next = i.next(); JSONArray jsonArray = jsonList.getJSONArray(next); // Do stuff with jsonArray, example: jsonArray.getString(0), jsonArray.getString(1); }
The exact warning is: Type safety: The expression of type Iterator needs unchecked conversion to conform to Iterator
So the question is how can I eradicate this warning?
Many thanks!
i realize this is an old thread, but for future searchers...
you can also infer a generic and cast the returns of the iterator methods...
Iterator<?> i = jsonList.keys(); while(i.hasNext()) { String next = (String) i.next(); ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With