The error received
Generally, the error Error parsing data org.json.JSONException ...
refers to the inability to process JSON.
For your particular case, you can read in the error message:
Error parsing data org.json.JSONException: Value of type java.lang.String can not be converted to JSONObject
What translated:
Error processing data org.json.JSONException: Value of type java.lang.String can not be converted to JSONObject
That tells us that a string
is being sent instead of an object, as expected.
Dealing with error
One way to deal with error in scenarios like this is to wrap your code in a try...catch
so you can try to work the data you receive while being able to catch any errors in a way that deal with them:
try {
JSONObject jobj = new JSONObject(response);
String succes = jobj.getString("success");
...
} catch (JSONException e) {
// ups, correu mal... vamos ver o que aconteceu
e.printStackTrace();
}