【问题标题】:parsing nested JSON array using volley library in android在 android 中使用 volley 库解析嵌套的 JSON 数组
【发布时间】:2019-09-26 13:33:14
【问题描述】:

如何使用 volley 库解析嵌套的 JSON 数组? 我的 JSON 数据结构截图。 https://prnt.sc/pbaea5

我需要坚持分值。

JSONArray jsonArray = response.getJSONArray("matches");

    for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jsonObjectMatchs = jsonArray.getJSONObject(i);

        // bat_team node is JSON Object
        JSONObject bat_teamData = jsonObjectMatchs.getJSONObject("bat_team");
        JSONArray jsonArrayInnings = bat_teamData.getJSONArray("innings");
        JSONObject jsonObjectInnings = jsonArrayInnings.getJSONObject(i);


        String bat_team_score = jsonObjectInnings.getString("score");
    }

【问题讨论】:

    标签: android json android-volley


    【解决方案1】:

    您需要进一步迭代 jsonArrayInnings 使用另一个循环,但在您的代码中,您使用的是父循环的 i。 它将无法正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多