如何解析侧面JSON阵列Android中的JSON数组

Aru*_*kur 1 arrays android json

我正在研究json解析.我正在以JSON数组的形式获得响应,并在另一个JSON数组中获得另一个JSON数组.我没有得到热解析.在json数组中获取json数组对象我在json中是新的,所以请需要帮助.

这是我的回答: -

      [
        [
            {
                "Postcode": "BR6 0NH",
                "Notes": null,
                "Name": "Tesco Pharmacy (Orpington), Bromley, London",
                "Phone": "01689 307447",
                "Address": "10 AUGUSTUS LANE, ORPINGTON",
                "ServiceId": 0,
                "Capacity": null,
                "URL": null,
                "Error": null
            },
            {
                "Postcode": "DA14 5BN",
                "Notes": null,
                "Name": "Tesco Pharmacy, (Edgington Way), Bromley, London",
                "Phone": "0208 258 9447",
                "Address": "EDGINGTON WAY, SIDCUP",
                "ServiceId": 0,
                "Capacity": null,
                "URL": null,
                "Error": null
            }
        ]
      ]
Run Code Online (Sandbox Code Playgroud)

Bir*_*dia 5

试试这种方式

 try {
            JSONArray mainArry = new JSONArray(strJsonResponse);
            JSONArray contentArray = mainArry.getJSONArray(0);
            for (int i =0 ;i<contentArray.length(); i++){
                JSONObject item = contentArray.getJSONObject(0);
                System.out.println("Postcode : " + item.getString("Postcode"));
                System.out.println("Notes : " + item.getString("Notes"));
                System.out.println("Phone : " + item.getString("Phone"));
                System.out.println("Address : " + item.getString("Address"));
                System.out.println("ServiceId : " + item.getString("ServiceId"));
                System.out.println("Capacity : " + item.getString("Capacity"));
                System.out.println("URL : " + item.getString("URL"));
                System.out.println("Error : " + item.getString("Error"));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)