Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.android.volley.ParseError: org.json.JSONException

I got this error from volley library

@Override
public void onErrorResponse(VolleyError error) {
    error.printStackTrace();
}

the error

com.android.volley.ParseError: org.json.JSONException: Value [{"id":"admin","name":"Admin"}] of type org.json.JSONArray cannot be converted to JSONObject

How can I receive the result as string and then I will process it using jackson ?

like image 850
Mohammed Subhi Sheikh Quroush Avatar asked Jan 08 '14 14:01

Mohammed Subhi Sheikh Quroush


1 Answers

If you want to receive the result as a string don't use the JSONRequest. Go with the simple Request class. Your problem is pretty simple the server is giving back a JSONArray with just one element inside. A JSONArray is not a JSONObject. That's why the parsing is failing.

like image 167
Pasquale Anatriello Avatar answered Sep 26 '22 00:09

Pasquale Anatriello