I have the following (using org.json.simple):
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
...
final JSONArray results = (JSONArray) responseObject.get("results");
results
.stream()
.filter(JSONObject.class::isInstance)
.map(JSONObject.class::cast)
.map(obj -> obj) // obj is still Object here, not JSONObject?
The problem is that after I call map to cast the stream elements to JSONObject, on the next call to map, the elements are still Object, not JSONObject. Not sure what I'm doing wrong here?