Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse JSON Array without Key

I am trying to parse the jsonArray but unable to understand this format,How to parse this type of jsonArray? Can anyone help me?

  "rows": [
                [
                    "/farmfresh",
                    "20171211",
                    "4"
                ],
                [
                    "/farmfresh/product/d",
                    "20171215",
                    "4"
                ],
                [
                    "/farmfresh/product/h",
                    "20171222",
                    "2"
                ]
            ]
like image 273
Aj 27 Avatar asked Dec 28 '17 06:12

Aj 27


1 Answers

Try this

try 
{    
    JSONObject resObject = new JSONObject("your json response");    
    JSONArray jsonArray = resObject.getJSONArray("rows");        

    for (int i = 0; i < jsonArray.length(); i++) {        
       JSONArray jsonArray1 = jsonArray.getJSONArray(i);

       for (int j = 0; j < jsonArray1.length(); j++) {

          Log.i("Value","->" +jsonArray1.getString(j));
       }
   }

} 
catch (JSONException e) 
{
    // TODO Auto-generated catch block
    e.printStackTrace();
}

OUTPUT

enter image description here

like image 149
Ratilal Chopda Avatar answered Oct 07 '22 00:10

Ratilal Chopda