if(jsonArray.getJSONObject(i).get("SECNO").toString()!=null && jsonArray.getJSONObject(i).get("SECNO").toString().trim()!="")
appointment.mSecNo =Integer.parseInt(jsonArray.getJSONObject(i).get("SECNO").toString());
else
appointment.mSecNo = -1;
In the previouse lines, when the value of jsonArray.getJSONObject(i).get("SECNO").toString() equales to ” it doesn’t be caught by the if statement ..
and I get this error message .. can't parse '' to integer
Don’t use
==or!=to compare strings in Java – it only compares the references, not the contents of the strings. Also, I doubt thattoStringwould ever return null. I suspect you want:(I don’t know what the type of
jsonArray.getJSONObject(i).get("SECNO")would be, hence theFoo.)In this particular case I’ve used
length() > 0to detect a non-empty string – but for more general equality, you’d want to useequals, so an alternative is: