android - 如何在 JSON 数组 Android 中解析 JSON 数组

标签 android json arrays

我正在研究 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
            }
        ]
      ]

最佳答案

试试这个

 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();
        }

关于android - 如何在 JSON 数组 Android 中解析 JSON 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24772245/

相关文章:

android - 如何查找 lat.lng 是否在谷歌地图中的某个半径圆内

java - KSOAP2 库类未找到异常

java - 解析 IMDB-API JSON

javascript - jquery 超大 stop_loop 重定向?

c++ - 二进制数据的 char * 的 fwrite 等价物

javascript - 为什么 reduce 函数输出数组中的项目数?

c# - 统一 AdMob - ClassNotFound : com. google.unity.ads.UnityAdListener

java - 如何从 HttpResponse 解析 Json 数据

javascript - 错误 Kendo UI Chart 图 e.slice 不是函数

Android:可滚动的图片库布局