JSONArrayRequest

33 views
Skip to first unread message

Dhruvi Khara

unread,
Jan 12, 2018, 5:13:15 AM1/12/18
to Volley Users
I have used JSONArrayRequest with POST method but i get Parser error

JsonArrayRequest newsReq = new JsonArrayRequest(Request.Method.POST,url,,new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {

for (int i = 0; i < response.length(); i++) {
try {

JSONObject obj = response.getJSONObject(i);
Categoryfeed feeds = new Categoryfeed(obj.getInt("id"),obj.getString("category"),obj.getString("slug"));

// adding movie to movies array
feedsList.add(feeds);

} catch (Exception e) {
System.out.println(e.getMessage());





Error is:I/Volley Error: com.android.volley.ParseError: org.json.JSONException: Value {"type":"success","content":[{"id":32,"category":"Action\/Adventure","slug":"actionadventure"},{"id":31,"category":"Anime\/Animation","slug":"animeanimation"},{"id":2,"category":"Autos & Vehicles","slug":"autos-vehicles"},{"id":33,"category":"Classics","slug":"classics"},{"id":23,"category":"Comedy","slug":"comedy"},{"id":35,"category":"Documentary","slug":"documentary"},{"id":36,"category":"Drama","slug":"drama"},{"id":27,"category":"Education","slug":"education"},{"id":24,"category":"Entertainment","slug":"entertainment"},{"id":37,"category":"Family","slug":"family"},{"id":1,"category":"Film & Animation","slug":"film-animation"},{"id":38,"category":"Foreign","slug":"foreign"},{"id":20,"category":"Gaming","slug":"gaming"},{"id":39,"category":"Horror","slug":"horror"},{"id":26,"category":"Howto & Style","slug":"howto-style"},{"id":30,"category":"Movies","slug":"movies"},{"id":10,"category":"Music","slug":"music"},{"id":25,"category":"News & Politics","slug":"news-politics"},{"id":29,"category":"Nonprofits & Activism","slug":"nonprofits-activism"},{"id":22,"category":"People & Blogs","slug":"people-blogs"},{"id":15,"category":"Pets & Animals","slug":"pets-animals"},{"id":40,"category":"Sci-Fi\/Fantasy","slug":"sci-fifantasy"},{"id":28,"category":"Science & Technology","slug":"science-technology"},{"id":18,"category":"Short Movies","slug":"short-movies"},{"id":42,"category":"Shorts","slug":"shorts"},{"id":43,"category":"Shows","slug":"shows"},{"id":17,"category":"Sports","slug":"sports"},{"id":41,"category":"Thriller","slug":"thriller"},{"id":44,"category":"Trailers","slug":"trailers"},{"id":19,"category":"Travel & Events","slug":"travel-events"},{"id":21,"category":"Videoblogging","slug":"videoblogging"}]} of type org.json.JSONObject cannot be converted to JSONArray

Reply all
Reply to author
Forward
0 new messages