列表视图在解析时未相应地显示数据 json

list view not showing data accordingly when parsing json

我正在将 json 解析为列表视图。数据解析得很好,但是数组适配器 class 中存在一些问题,它没有相应地显示视图。

public void parseJson(JSONObject json) {
    try {
            JSONArray posts = json.getJSONArray("resume");
            feedList = new ArrayList<JsonItem>();
            for (int i = 0; i < posts.length(); i++) {
                JSONObject post = (JSONObject) posts.getJSONObject(i);
                JsonItem item = new JsonItem();
                JSONArray cast = post.getJSONArray("Education");
                Log.i("lenght", Integer.toString(cast.length()));
                if (cast != null && cast.length()>0) {
                    for(int j =0 ;j<cast.length();j++){
                    JSONObject casts = (JSONObject)cast.getJSONObject(j);
                        item.setTitle(casts.getString("Title"));
                        feedList.add(item);
                        Log.i("feedsize", feedList.get(j).toString());
                }
            }
        }
    }catch(JSONException e){
        e.printStackTrace();
}

Json数组:

 {
    "resume":[
        {
            "Education":[
                {
                    "Title":"Post Graduation",
                    "Degree":"M. Tech."
                },
                {
                    "Title":"Graduation",
                    "Degree":"B. Tech."
                }
            ]
        }
    ]
}

我这个数组有两个标题:Post毕业毕业

但在布局中它只显示一个值:Graduation

在内部循环而不是外部循环中实例化 JsonItem 对象,方法如下:

public void parseJson(JSONObject json) {
try {
        JSONArray posts = json.getJSONArray("resume");
        feedList = new ArrayList<JsonItem>();
        for (int i = 0; i < posts.length(); i++) {
            JSONObject post = (JSONObject) posts.getJSONObject(i);

            JSONArray cast = post.getJSONArray("Education");
            Log.i("lenght", Integer.toString(cast.length()));
            if (cast != null && cast.length()>0) {
                for(int j =0 ;j<cast.length();j++){                       

                   JsonItem item = new JsonItem();

                   JSONObject casts = (JSONObject)cast.getJSONObject(j);
                   item.setTitle(casts.getString("Title"));
                   feedList.add(item);
                   Log.i("feedsize", feedList.get(j).toString());
                }
            }


        }
    } catch (JSONException e) {
         e.printStackTrace();
    }
}