I have a JSONObject which I am parsing and sometimes some of the data is null.
In this case, ReportId = null..so, I tried to use a ternary operator to prevent the ClassCastException, however, it doesn’t work.
The specific object throwing the error has "ReportId":null….can I not do this?
Line:
item.setReportId((jsonObj.get("ReportId") != null || jsonObj.get("ReportId") != "null") ? (Integer)jsonObj.get("ReportId") : 0);
I just had a look at the documentation for JSONObject, it appears to have a number of convenience methods. For example: