RequestQueue queue = Volley.newRequestQueue(this); StringRequest req = new StringRequest(JsonUrl, new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); JSONArray jsonArray = jsonObject.getJSONArray("data"); for (int i = 0; i < jsonArray.length(); i++) { // Here i am getting the all JSONObjects from JSONArray, //how can i filter the JSONObjects that // only having "publishtype": "PUBLISHED". JSONObject jsonObjectFromArray = jsonArray.getJSONObject(i); } } catch (JSONException e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show(); } }); queue.add(req);
for (int i = 0; i < jsonArray.length(); i++) { JSONObject obj= jsonArray.getJSONObject(i); if(obj.getString("publishtype").equals("PUBLISHED")) { // add this item in some collection i.e PublishedList, and later use this collection } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)