-1

I´m using volley to send a JSONObject to the server of my application, I was looking for how to catch a JSONArray as request, but I can put "Response.Listener.JSONArray", it doesn´t work.

Right now I have this:

JsonObjectRequest jsonArrayRequest = new JsonObjectRequest(Request.Method.POST,
url, obj,

new Response.Listener <JSONObject > () {@Override
    public void onResponse(JSONObject response) {
        //only for test.
        Log.d("SendRequestJsonPost", response.toString());
    }

}, new Response.ErrorListener() {

}

Ok, when I send a JSONObject to the server, I wait to receive a JSONArray, but when I change from JSONObject to JSONArray I get errors on my code.

Someone knows how to do this?

Kashif Nazar
  • 20,775
  • 5
  • 29
  • 46
BigBugCreator
  • 1,009
  • 4
  • 17
  • 34
  • I had the same problem, check this out. https://stackoverflow.com/questions/30888485/how-i-send-a-jsonobject-and-recive-a-jsonarray – carl2100 Jun 22 '15 at 14:43

1 Answers1

0

Try this:

 JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.POST,url, obj,
    new Response.Listener<JSONArray>() {
    @Override
    public void onResponse(JSONArray response) {
    //only for test.
    Log.d("SendRequestJsonPost", response.toString());
    }

    }, new Response.ErrorListener() {

    }
Abhishek Batra
  • 1,539
  • 1
  • 18
  • 45
  • @LeonardoCavani You have used JsonObjectResponce class, you should JsonArrayRequest... Line 5 according to your screenhshot – Abhishek Batra Jun 17 '15 at 11:30