Android : parse.com java.lang.ClassCastException: java.util.HashMap cannot be cast to org.json.JSONObject

on Monday, July 7, 2014


My code generally works except sometimes it crashes with the above error. It happens on this line of code...



JSONObject profile = (JSONObject) currentUser.get("profile");


It happens only sometimes when I hit the back button. Which makes it awfully hard for me to understand what is causing the problem. Why would it be a hashmap?


Can anyone point me in the right direction?



ParseUser currentUser = ParseUser.getCurrentUser();

if (currentUser.has("profile")) {
JSONObject profile = (JSONObject) currentUser.get("profile");
}

0 comments:

Post a Comment