使用Volley在JSONArray中获取JSONObject

时间:2018-11-16 12:23:15

标签: android android-volley

我想在de array中获取特定数据,在本例中为product:name,description和Recommendation_price,但是我不确定如何做到这一点

 progressDialog = ProgressDialog.show(OrderModActivity.this,"Atencion!","Cargando...");
    RequestQueue queue = Volley.newRequestQueue(this);
    String url = "https://url/blablabla/";
    StringRequest stringRequest = new StringRequest(
            Request.Method.GET,
            url,
            response -> {
                progressDialog.dismiss();
                Log.i("Response", response);

                try {

                    JSONArray json = new JSONArray(response);
                    for(int i = 0; i< json.length(); i++){
                        String jsonObject1 = json.getString("product");


                    }

这是回应

  [{
    "id": 3192,
    "product": {
        "id": 3178,
        "subcategory": {
            "id": 83,
            "category": {
                "id": 16,
                "name": "Carnes",
                "picture": "/products/carnes_o7w1NNC.png"
            },
            "name": "Otros"
        },
        "name": "Borrar",
        "description": "1 kg",
        "picture": "/IMG_3130.PNG",
        "suggested_price": "5000",
        "status": true,
        "sku": ""
    },
    "base_price": "22.22",
    "enable": true
 }]

0 个答案:

没有答案