2

I want to get “file” in “media_gallery_entries” JSONArray by Volley for loop

Volley

val item = ArrayList<RecyData>()
val jsonRequest = object : JsonObjectRequest(Request.Method.GET, url, null,

    Response.Listener { response ->

       try {

            val jsonArrayItems = response.getJSONArray("items")
            val jsonSize = jsonArrayItems.length()

            for (i in 0 until jsonSize) {
                val jsonObjectItems = jsonArrayItems.getJSONObject(i)
                val pName = jsonObjectItems.getString("name")
                val pPrice = jsonObjectItems.getInt("price")
                item.add(RecyData(pName, pPrice, pImage))
            }
       } catch (e: JSONException) {
             e.printStackTrace()
       }

Data

{
   "items": [
       {
           "id": 1,
           "sku": "10-1001",
           "name": "item01",
           "price": 100,
           "media_gallery_entries": [
               {
                   "id": 1,
                   "file": "//1/0/10-28117_1_1.jpg"
               }
           ]
       }
   ]
}