I have some data stored in Java elements and I need to return it in a given format - JSONObject. While my implementation works fine, I\'m still getting a warning message fro
If you can't switch to another library or modify the code of this library to make it generic, the only other option would be to write a wrapper around this library which uses it, and properly supports generics.
So you would have your own JSONObject
class which would contain an org.json.simple.JSONObject
, would extend HashMap<String, Object>
and implement Map<String, Object>
, and would contain forwarding methods for all the methods of org.json.simple.JSONObject
.
You would still have to put @SuppressWarnings("unchecked")
in this class, but it would be limited to this class, and all the rest of your code could be free of generic warnings or the suppression of them.