本文介绍了Android应用内返回数组为[]或ArrayList的内存分配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新来的Java和Android,我试图解析从链接类的数据,但我不能工作,如何从一些内/嵌套JSONArrays的检索一个JSONObjects?

我可以检索从外部JSONArray的对象,但我看不到如何从的StorlineData类中细分内JSONArrays检索嵌套JSONArray列表对象。

当我试图从内/嵌套JSONArrays响应如下分析数据:


在此先感谢您的帮助。

JSON(我无法从trackPointsData和PlacesData数据)

  [
    {
        日期:20121212,
        摘要:
            {
                活动:行走,
                群:走,
                持续时间:3333,
                距离:3333,
                台阶:3333,
                卡路里:300
            },        ]
        段:[
            {
                类型:地方,
                startTime时:20121212T000000 + 0200,
                ENDTIME:20121212T071430 + 0200,
                地方:{
                    标识:1,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:搬家,
                startTime时:20121212T071430 + 0200,
                ENDTIME:20121212T074617 + 0200,
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T071430 + 0200,
                        ENDTIME:20121212T072732 + 0200,
                        持续时间:782,
                        距离:1251,
                        台阶:1353
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T071430 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T072732 + 0200
                            }
                        ]
                    },
                    {
                        活动:运输,
                        群:运输,
                        手册:假的,
                        startTime时:20121212T072732 + 0200,
                        ENDTIME:20121212T074616 + 0200,
                        持续时间:1124
                        距离:8443,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T072732 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T074208 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T074617 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T074617 + 0200,
                ENDTIME:20121212T100051 + 0200,
                地方:{
                    ID:2,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:walking_on_treadmill
                        群:走,
                        手册:真实,
                        持续时间:270,
                        台阶:303,
                        卡路里:30,
                        航迹:[]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },            {
                类型:地方,
                startTime时:20121212T100715 + 0200,
                ENDTIME:20121212T110530 + 0200,
                地方:{
                    ID:4,
                    名:测试,
                    类型:四方
                    foursquareId:4df0fdb17d8ba370a011d24c,
                    foursquareCategoryIds:4bf58dd8d48988d125941735],
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T101215 + 0200,
                        ENDTIME:20121212T101255 + 0200,
                        持续时间:40,
                        距离:18,
                        台阶:37,
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T101215 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T101255 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:搬家,
                startTime时:20121212T110530 + 0200,
                ENDTIME:20121212T111129 + 0200,
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T110530 + 0200,
                        ENDTIME:20121212T111128 + 0200,
                        持续时间:358,
                        距离:493,
                        台阶:441,
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110531 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110536 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110947 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T111017 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T111129 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T111129 + 0200,
                ENDTIME:20121212T153638 + 0200,
                地方:{
                    ID:2,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:尊巴
                        手册:真实,
                        持续时间:570,
                        卡路里:200,
                        航迹:[]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },            {
                类型:地方,
                startTime时:20121212T160744 + 0200,
                ENDTIME:20121212T232730 + 0200,
                地方:{
                    标识:1,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                LASTUPDATE:20130317T121143Z
            }
        ]
        caloriesIdle:1785年,
        LASTUPDATE:20130317T121143Z
    }
]

主要活动:

  ...
    私人MovesHandler< ArrayList的< StorylineData>> storylineHandler =新MovesHandler< ArrayList的< StorylineData>>(){
                @覆盖
                公共无效的onSuccess(ArrayList的< StorylineData>的结果){
                    toggleProgress(假);
                    updateResponse(
...
                                +-----------段1 ------- \\ t的
                                +开始时间:\\ t的。+ result.get(0).getSegments()得到(0).getStartTime()+\\ n
                                + - 活动于阵列\\ t+\\ n
                                + - 开始时间:\\ t+ ...                        +-----------段2 ------- \\ t+\\ n
                        + - 航迹:\\ t+ result.get(0).getTrackPoints()+\\ n// ====阵列添加
                        + - FoursquareId:\\ t+ result.get(0).getFoursquareId()+\\ n
                        + - 行动:\\ t+ result.get(0).getActivities()+\\ n
                            +。 - 四方编号:\\ t+ result.get(0).getSegments()得到(0).getPlace()getFoursquareId()+\\ n
                            + - 四方编号:\\ t+ result.get(0).getFoursquareId()+\\ n
                            + - 四方的类别ID:\\ t的。+ result.get(0).getSegments()得到(0).getPlace()getFoursquareCategoryIds()+\\ n
                            + - 活动:\\ t+ result.get(0).getSegments()得到(0).getActivities()+\\ n
);        }

...

StorylineData类(我想找回从这里内JSONArrays一个JSONObjects在storylineData类):

  / **
 *解析一个{@link org.json.JSONObject}从故事情节{@link org.json.JSONArray},然后返回相应的{@link StorylineData}对象。
 *
 * @参数的JSONObject:从服务器接收到的故事情节JSON对象
 * @返回相应的{@link StorylineData}
 * /
公共静态StorylineData解析(JSONObject的JSONObject的)抛出JSONException {
    如果(JSONObject的!= NULL){        StorylineData storylineData =新StorylineData();        storylineData.date = jsonObject.optString(日期);
        storylineData.caloriesIdle = jsonObject.optInt(caloriesIdle);
        storylineData.lastUpdate = jsonObject.optString(LASTUPDATE);
        storylineData.summary =新的ArrayList<>();
        storylineData.segments =新的ArrayList<>();        JSONArray summariesJsonArray = jsonObject.optJSONArray(摘要);        如果(summariesJsonArray!= NULL)
        的for(int i = 0; I< summariesJsonArray.length();我++){            JSONObject的summaryJsonObject = summariesJsonArray.optJSONObject(I)                    如果(summaryJsonObject!= NULL){
                    summariesJsonArray.getJSONObject(ⅰ).getString(距离);                        串组= summaryJsonObject.optString(「本集团」);                        整数距离= summaryJsonObject.optInt(距离);
                        storylineData.setDistance(距离);
...
                    storylineData.summary.add(SummaryData.parse(summaryJsonObject));                        Log.d(StorylineDataCls \\ t SJO,summaryJsonObject.toString()+日志\\ n);
                        的System.out.println(打印距离+ summariesJsonArray.getJSONObject㈠.getString(距离));
                        的System.out.println(打印摘要+ summaryJsonObject);                }
            }        JSONArray segmentsJsonArray = jsonObject.optJSONArray(段);
        如果(segmentsJsonArray!= NULL){            的for(int i = 0; I< segmentsJsonArray.length();我++){
                的JSONObject段= segmentsJsonArray.optJSONObject(ⅰ);                如果(段!= NULL){                    JSONArray activitiesJsonArray = segment.optJSONArray(活动);
                    如果(activitiesJsonArray!= NULL){                        对于(INT J = 0; J< activitiesJsonArray.length(); J ++){
                            JSONObject的航迹点= activitiesJsonArray.optJSONObject(J);
                            如果(航迹点!= NULL){
                        ...
                    storylineData.trackPoints.add(TrackPointsData.parse(航迹点));
                                 }
                        }
                    }            ..
                    Log.d(StorylineDataCls \\ t SSO,segment.toString());
                    的System.out.println(打印段+段);
                    //System.out.println(\"print段+段);
                    的System.out.println(打印segmentsJsonArray+ segmentsJsonArray);                }
            }
        }
        返回storylineData;
    }
    返回null;
}

============在链接CLASSES PARSER方法=====

PlaceData类:

  / **
     *解析一个地方的{@link org.json.JSONObject},然后返回相应的{@link PlaceData}对象。
     * @参数的JSONObject:在地点JSON对象解析
     * @返回相应的{@link PlaceData}
     * /
    公共静态PlaceData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
            PlaceData placeData =新PlaceData();        placeData.id = jsonObject.optString(ID);
        placeData.name = jsonObject.optString(名称);
        placeData.type = jsonObject.optString(类型);
        placeData.foursquareId = jsonObject.optString(foursquareId);        JSONObject的位置= jsonObject.optJSONObject(位置);
        如果(位置!= NULL){
            placeData.location = LocationData.parse(位置);
        }        JSONArray trackPointsJSONArray = jsonObject.optJSONArray(foursquareCategoryIds);
        placeData.foursquareCategoryIds =新的ArrayList<串GT;();
        如果(trackPointsJSONArray!= NULL){
            的for(int i = 0; I< trackPointsJSONArray.length();我++){
                字符串categoryId = trackPointsJSONArray.optString(I)
                如果(的categoryId =空&放大器;!&放大器; categoryId.length()大于0){                    placeData.foursquareCategoryIds.add(的categoryId);
                }
            }
        }
        返回placeData;
    }
    返回null;
}

}

LocationData类:

  / **
     *解析一个{@link org.json.JSONObject}从航迹点{@link org.json.JSONArray},然后返回对应的
     * {@link LocationData}对象。
     * @参数的JSONObject:在指点杆JSON对象解析
     * @返回相应的{@link LocationData}
     * /
    公共静态LocationData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
                LocationData trackPointsData =新LocationData();
                trackPointsData.lat = jsonObject.optString(纬度);
                trackPointsData.lon = jsonObject.optString(LON);
            返回trackPointsData;
        }
        返回null;
    }}

TrackPointData类:

  / **
 *解析一个{@link org.json.JSONObject}从航迹点{@link org.json.JSONArray},然后返回对应的
 * {@link TrackPointsData}对象。
 * @参数的JSONObject:在指点杆JSON对象解析
 * @返回相应的{@link TrackPointsData}
 * /
公共静态TrackPointsData解析(的JSONObject的JSONObject){
    如果(JSONObject的!= NULL){
            TrackPointsData trackPointsData =新TrackPointsData();
            trackPointsData.lat = jsonObject.optString(纬度);
            trackPointsData.lon = jsonObject.optString(LON);
            trackPointsData.time = jsonObject.optString(时间);
            返回trackPointsData;
    }
    返回null;
}}

ActivityData类:

  / **
     *从活动解析一个{@link org.json.JSONObject} {@link org.json.JSONArray},然后返回对应的
     * {@link ActivityData}对象。
     * @参数的JSONObject:在活动JSON对象解析
     * @返回相应的{@link ActivityData}
     * /
    公共静态ActivityData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
            ActivityData activityData =新ActivityData();
                activityData.activity = jsonObject.optString(活动);
                activityData.group = jsonObject.optString(「本集团」);
                activityData.manual = jsonObject.optString(手册);
                activityData.startTime = jsonObject.optString(startTime时);
                activityData.endTime = jsonObject.optString(ENDTIME);
                activityData.duration = jsonObject.optInt(时间);
                activityData.distance = jsonObject.optInt(距离);
                activityData.steps = jsonObject.optInt(步);
                activityData.calories = jsonObject.optInt(卡路里);
            JSONArray trackPointsJSONArray = jsonObject.optJSONArray(航迹点);                activityData.trackPoints =新的ArrayList< TrackPointsData>();
                如果(trackPointsJSONArray!= NULL){
                    的for(int i = 0; I< trackPointsJSONArray.length();我++){
                        JSONObject的summaryJsonObject = trackPointsJSONArray.optJSONObject(I)
                        如果(summaryJsonObject!= NULL){                            activityData.trackPoints.add(TrackPointsData.parse(summaryJsonObject));
                        }
                    }
                }                返回activityData;
        }
        返回null;
    }
}

SegmentData类:

  / **
     *解析一个{@link org.json.JSONObject}从细分{@link org.json.JSONArray},然后返回相应的{@link SegmentData}对象。
     * @参数的JSONObject:细分JSON对象解析
     * @返回相应的{@link SegmentData}
     * /
    公共静态SegmentData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
            SegmentData segmentData =新SegmentData();
            segmentData.type = jsonObject.optString(类型);
            segmentData.startTime = jsonObject.optString(startTime时);
            segmentData.endTime = jsonObject.optString(ENDTIME);
            segmentData.lastUpdate = jsonObject.optString(LASTUPDATE);
            segmentData.name = jsonObject.optString(名称);            JSONArray activitiesJSONArray = jsonObject.optJSONArray(活动);
            segmentData.activities =新的ArrayList< ActivityData>();
            如果(activitiesJSONArray!= NULL){
                的for(int i = 0; I< activitiesJSONArray.length();我++){
                    JSONObject的activityJsonObject = activitiesJSONArray.optJSONObject(I)
                    如果(activityJsonObject!= NULL){
                        placeData =(PlaceData)activityJsonObject.opt(将String.valueOf(placeData));
                        segmentData.setPlace(placeData);                        segmentData.activities.add(ActivityData.parse(activityJsonObject));
                    }
                }
            }            JSONObject的placeJsonObject = jsonObject.optJSONObject(地方);
            如果(placeJsonObject!= NULL){
                segmentData.place = PlaceData.parse(placeJsonObject);
            }            返回segmentData;
        }
        返回null;
    }
}

SummaryData类:

  / **
     *解析一个{@link org.json.JSONObject}从摘要{@link org.json.JSONArray},然后返回相应的{@link SummaryData}对象。
     * @参数的JSONObject:摘要JSON对象解析
     * @返回相应的{@link SummaryData}
     * /
    公共静态SummaryData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
                SummaryData总结=新SummaryData();
                summary.activity = jsonObject.optString(活动);
                summary.group = jsonObject.optString(「本集团」);
                summary.duration = jsonObject.optInt(时间);
                summary.distance = jsonObject.optInt(距离);
                summary.steps = jsonObject.optInt(步);
                summary.calories = jsonObject.optInt(卡路里);            //Log.d(\"json,summary.toString());            返回总结;
        }
        返回null;
    }
}

HTTPCall类:
...

 公共静态无效getDailyStorylineList(最终MovesHandler< ArrayList的< StorylineData>>处理程序,
                                             最后弦乐specificSummary,
                                             最后弦乐的,
                                             最终的字符串,
                                             最后弦乐pastDays,
                                             最后弦乐updatedSince,
                                             最终布尔needTrackPoints){
        新主题(新的Runnable接口(){
            @覆盖
            公共无效的run(){
                尝试{
                    / *刷新访问令牌,如果只AuthData.MOVES_REFRESHBEFORE天都没有过期当前令牌* /
                    AuthData.refreshAccessTokenIfNeeded();                    / *交换我们登录后获得授权code以获得访问令牌* /
                    HashMap的<字符串,字符串> namevaluepairs中=新的HashMap<字符串,字符串>();
                    nameValuePairs.put(ACCESS_TOKEN,AuthData.getAuthData()getAccessToken());                   //如果(specificSummary =空&放大器;!&放大器; specificSummary.length()大于0)nameValuePairs.put(specificSummary,specificSummary); // ATT                    如果(从=空&放大器;!&放大器; from.length()大于0)nameValuePairs.put(来自,从);
                    如果(至=空&放大器;!&放大器; to.length()大于0)nameValuePairs.put(到,到);
                    如果(pastDays =空&放大器;!&放大器; pastDays.length()大于0)nameValuePairs.put(pastDays,pastDays);
                    如果(updatedSince =空&放大器;!&放大器; updatedSince.length()大于0)nameValuePairs.put(updatedSince,updatedSince);
                    如果(needTrackPoints)nameValuePairs.put(航迹,真);
                    网址URL =新的URL(MovesAPI.API_BASE + MovesAPI.API_PATH_STORYLINE +(specificSummary = NULL specificSummary!?)++ Uti​​lities.en codeUrl作者(namevaluepairs中));
                    HttpURLConnection类的URLConnection =(HttpURLConnection类)url.openConnection();
                    urlConnection.setRequestMethod(GET);
                    urlConnection.setDoInput(真);
                    urlConnection.connect();                    如果(urlConnection.getResponse code()!= 200){
                        / *从移动所有其他HTTP错误一股脑这里* /
                        handler.onFailure(getErrorStatus(Utilities.readStream(urlConnection.getErrorStream()),urlConnection.getResponse code()),服务器无法成功响应(+ urlConnection.getResponse code()+) );
                        返回;
                    }                    串响应= Utilities.readStream(urlConnection.getInputStream());
                    Object对象=新JSONTokener(响应).nextValue();
                    如果(对象的instanceof JSONArray),其中{
                        JSONArray jsonArray =(JSONArray),其中对象;
                        ArrayList的< StorylineData> storylineData =新的ArrayList< StorylineData>();
                        如果(jsonArray!= NULL){
                            的for(int i = 0; I< jsonArray.length();我++){
                                JSONObject的storylineJsonObject = jsonArray.optJSONObject(I)
                                如果(storylineJsonObject!= NULL){
                                    storylineData.add(StorylineData.parse(storylineJsonObject));
                                }
                            }
                        }
                        handler.onSuccess(storylineData);
                    }其他{
                        handler.onFailure(MovesStatus.INVALID_RESPONSE,预期从服务器JSONArray,但未能成功);
                    }                }赶上(例外前){
                    ex.printStackTrace();
                    handler.onFailure(MovesStatus.UNEXPECTED_ERROR,发生意外错误,请检查logcat的);
                }
            }
        })。开始();
    }

MovesHandler类

  / **
 *此接口将作为谁通知所有的成功和失败的处理程序
 *
 *
 * @参数< T> :泛型类,这可能将是成功后的响应类型
 * @see MovesStatus
 * /
公共接口MovesHandler< T> {// T代表泛型类型    / **
     *实现此方法来获取成功的通知,结果一起
     * @参数结果:此处理程序完成操作的结果
     * /
    公共无效的onSuccess(T结果);    / **
     *实现此方法来获取失败的通知与{@link MovesStatus} code和一条简短的消息一起
     * @参数状态:失败的状态code
     * @参数信息:关于失败背后的原因,一条短信息
     * /
    公共无效onFailure处(MovesStatus状态,字符串消息);
}

MovesAPI类

  / **
     *获取日常故事情节用户。
     * @see< A HREF =htt​​ps://dev.moves-app.com/docs/api_storyline>移动开发者页面每日故事情节< / A>
     * @see SummaryListData
     * @参数处理程序:的实现{@link MovesHandler}与{@link的ArrayList} {@link StorylineData}。
     *请求结束时该处理器将得到通知。
     * @参数日期:日期YYYYMMDD或yyyy-mm-dd格式
     * @参数updatedSince:[可选]如果设置,仅返回的数据已经更新以来天
     *鉴于时间戳为ISO 8601(yyyyMMdd'T'HHmmssZ)格式,通过< code>空< / code>如果不是必需的。
     * @参数needTrackPoints:如果为true,则返回的活动还包括{@link TrackPointsData}信息。
     *包括轨迹点限制查询的范围为7天。
     * /
    公共静态无效getStoryline_SingleDay(MovesHandler< ArrayList的< StorylineData>>处理程序,字符串日期,字符串updatedSince,布尔needTrackPoints){
        如果(AuthData.isAuthenticated()){
            HTTPCall.getDailyStorylineList(处理程序/+日期,NULL,NULL,NULL,updatedSince,needTrackPoints);
        }其他{
            handler.onFailure(MovesStatus.NOT_AUTHENTICATED,你还没通过身份验证与所需的范围!);
        }
    }

SummaryListData类:

 公共静态SummaryListData解析(的JSONObject的JSONObject){
        如果(JSONObject的!= NULL){
                SummaryListData总结=新SummaryListData();                summary.date = jsonObject.optString(日期);
                summary.caloriesIdle = jsonObject.optString(caloriesIdle);
                summary.lastUpdate = jsonObject.optString(LASTUPDATE);
                summary.summaries =新的ArrayList< SummaryData>();                JSONArray summariesJsonArray = jsonObject.optJSONArray(摘要);
                如果(summariesJsonArray!= NULL){
                    的for(int i = 0; I< summariesJsonArray.length();我++){
                        JSONObject的summaryJsonObject = summariesJsonArray.optJSONObject(I)
                        如果(summaryJsonObject!= NULL){
                            summary.summaries.add(SummaryData.parse(summaryJsonObject));                            Log.d(summaryHandler,summaryJsonObject.toString());
                        }
                    }
                }                返回总结;
        }
        返回null;
    }
}


解决方案

这是您的有效JSON响应

  [
    {
        日期:20121212,
        摘要:
            {
                活动:行走,
                群:走,
                持续时间:3333,
                距离:3333,
                台阶:3333,
                卡路里:300
            }
        ]
        段:[
            {
                类型:地方,
                startTime时:20121212T000000 + 0200,
                ENDTIME:20121212T071430 + 0200,
                地方:{
                    标识:1,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:搬家,
                startTime时:20121212T071430 + 0200,
                ENDTIME:20121212T074617 + 0200,
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T071430 + 0200,
                        ENDTIME:20121212T072732 + 0200,
                        持续时间:782,
                        距离:1251,
                        台阶:1353
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T071430 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T072732 + 0200
                            }
                        ]
                    },
                    {
                        活动:运输,
                        群:运输,
                        手册:假的,
                        startTime时:20121212T072732 + 0200,
                        ENDTIME:20121212T074616 + 0200,
                        持续时间:1124
                        距离:8443,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T072732 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T074208 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T074617 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T074617 + 0200,
                ENDTIME:20121212T100051 + 0200,
                地方:{
                    ID:2,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:walking_on_treadmill
                        群:走,
                        手册:真实,
                        持续时间:270,
                        台阶:303,
                        卡路里:30,
                        航迹:[]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T100715 + 0200,
                ENDTIME:20121212T110530 + 0200,
                地方:{
                    ID:4,
                    名:测试,
                    类型:四方
                    foursquareId:4df0fdb17d8ba370a011d24c,
                    foursquareCategoryIds:[
                        4bf58dd8d48988d125941735
                    ]
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T101215 + 0200,
                        ENDTIME:20121212T101255 + 0200,
                        持续时间:40,
                        距离:18,
                        台阶:37,
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T101215 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T101255 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:搬家,
                startTime时:20121212T110530 + 0200,
                ENDTIME:20121212T111129 + 0200,
                活动:
                    {
                        活动:行走,
                        群:走,
                        手册:假的,
                        startTime时:20121212T110530 + 0200,
                        ENDTIME:20121212T111128 + 0200,
                        持续时间:358,
                        距离:493,
                        台阶:441,
                        卡路里:99,
                        航迹:[
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110531 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110536 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T110947 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T111017 + 0200
                            },
                            {
                                纬度:55.55555,
                                LON:33.33333,
                                时间:20121212T111129 + 0200
                            }
                        ]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T111129 + 0200,
                ENDTIME:20121212T153638 + 0200,
                地方:{
                    ID:2,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                活动:
                    {
                        活动:尊巴
                        手册:真实,
                        持续时间:570,
                        卡路里:200,
                        航迹:[]
                    }
                ]
                LASTUPDATE:20130317T121143Z
            },
            {
                类型:地方,
                startTime时:20121212T160744 + 0200,
                ENDTIME:20121212T232730 + 0200,
                地方:{
                    标识:1,
                    类型:未知,
                    位置: {
                        纬度:55.55555,
                        LON:33.33333
                    }
                },
                LASTUPDATE:20130317T121143Z
            }
        ]
        caloriesIdle:1785年,
        LASTUPDATE:20130317T121143Z
    }
]

这是相应的POJO类

 进口的java.util.ArrayList;
进口的java.util.HashMap;
进口的java.util.List;
进口的java.util.Map;
进口javax.annotation.Generated;
进口com.fasterxml.jackson.annotation.JsonAnyGetter;
进口com.fasterxml.jackson.annotation.JsonAnySetter;
进口com.fasterxml.jackson.annotation.JsonIgnore;
进口com.fasterxml.jackson.annotation.JsonInclude;
进口com.fasterxml.jackson.annotation.JsonProperty;
进口com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
活动,
手册,
持续时间,
卡路里,
航迹
})
公共类活动{@JsonProperty(活动)
私人字符串的活动;
@JsonProperty(手动)
私人布尔手册;
@JsonProperty(持续时间)
私人整数时间;
@JsonProperty(卡路里)
私人整数热量;
@JsonProperty(航迹点)
私人列表<对象>航迹点=新的ArrayList<对象>();
@JsonIgnore
私人地图<弦乐,对象> additionalProperties =新的HashMap<弦乐,对象>();/ **
*
* @返回
* 活动
* /
@JsonProperty(活动)
公共字符串getActivity(){
返回的活动;
}/ **
*
* @参数活动
* 活动
* /
@JsonProperty(活动)
公共无效setActivity(字符串活动){
this.activity =活动;
}/ **
*
* @返回
*本手册
* /
@JsonProperty(手动)
公共布尔getManual(){
返回手册;
}/ **
*
* @参数手册
*本手册
* /
@JsonProperty(手动)
公共无效setManual(布尔手动){
this.manual =手册;
}/ **
*
* @返回
*持续时间
* /
@JsonProperty(持续时间)
公共整数getDuration(){
返回时间;
}/ **
*
* @参数时间
*持续时间
* /
@JsonProperty(持续时间)
公共无效setDuration(整数时间){
this.duration =持续时间;
}/ **
*
* @返回
*卡路里
* /
@JsonProperty(卡路里)
公共整数getCalories(){
返回的热量;
}/ **
*
* @参数卡路里
*卡路里
* /
@JsonProperty(卡路里)
公共无效setCalories(整数卡路里){
this.calories =热量;
}/ **
*
* @返回
*本航迹
* /
@JsonProperty(航迹点)
公开名单<对象> getTrackPoints(){
返回航迹点;
}/ **
*
* @参数航迹
*本航迹
* /
@JsonProperty(航迹点)
公共无效setTrackPoints(列表<对象>航迹点){
this.trackPoints =航迹点;
}@JsonAnyGetter
公共地图<弦乐,对象> getAdditionalProperties(){
返回this.additionalProperties;
}@JsonAnySetter
公共无效setAdditionalProperty(字符串名称,对象的值){
this.additionalProperties.put(名称,值);
}}

您的位置类

 进口的java.util.HashMap;
进口的java.util.Map;
进口javax.annotation.Generated;
进口com.fasterxml.jackson.annotation.JsonAnyGetter;
进口com.fasterxml.jackson.annotation.JsonAnySetter;
进口com.fasterxml.jackson.annotation.JsonIgnore;
进口com.fasterxml.jackson.annotation.JsonInclude;
进口com.fasterxml.jackson.annotation.JsonProperty;
进口com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated(org.jsonschema2pojo)
@JsonPropertyOrder({
纬度,
LON
})
公共类位置{@JsonProperty(纬度)
私人双重纬度;
@JsonProperty(LON)
私人双LON;
@JsonIgnore
私人地图<弦乐,对象> additionalProperties =新的HashMap<弦乐,对象>();/ **
*
* @返回
*纬度
* /
@JsonProperty(纬度)
公共双getLat(){
返回纬度;
}/ **
*
* @参数纬度
*纬度
* /
@JsonProperty(纬度)
公共无效setLat(双人间LAT){
this.lat =纬度;
}/ **
*
* @返回
*本LON
* /
@JsonProperty(LON)
公共双getLon(){
返回LON;
}/ **
*
* @参数LON
*本LON
* /
@JsonProperty(LON)
公共无效setLon(双人间LON){
this.lon = LON;
}@JsonAnyGetter
公共地图<弦乐,对象> getAdditionalProperties(){
返回this.additionalProperties;
}@JsonAnySetter
公共无效setAdditionalProperty(字符串名称,对象的值){
this.additionalProperties.put(名称,值);
}}

您将类

 进口的java.util.HashMap;
进口的java.util.Map;
进口javax.annotation.Generated;
进口com.fasterxml.jackson.annotation.JsonAnyGetter;
进口com.fasterxml.jackson.annotation.JsonAnySetter;
进口com.fasterxml.jackson.annotation.JsonIgnore;
进口com.fasterxml.jackson.annotation.JsonInclude;
进口com.fasterxml.jackson.annotation.JsonProperty;
进口com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
ID,
类型,
位置
})
公共类场所{@JsonProperty(ID)
私人整数ID;
@JsonProperty(类型)
私人字符串类型;
@JsonProperty(位置)
私人位置定位;
@JsonIgnore
私人地图<弦乐,对象> additionalProperties =新的HashMap<弦乐,对象>();/ **
*
* @返回
*本ID
* /
@JsonProperty(ID)
公共整数的getId(){
返回ID;
}/ **
*
* @参数ID
*本ID
* /
@JsonProperty(ID)
公共无效SETID(整数ID){
this.id = ID;
}/ **
*
* @返回
* 方式
* /
@JsonProperty(类型)
公共字符串的getType(){
返回类型;
}/ **
*
* @参数类型
* 方式
* /
@JsonProperty(类型)
公共无效的setType(字符串类型){
this.type =类型;
}/ **
*
* @返回
* 那个地点
* /
@JsonProperty(位置)
公共场所的getLocation(){
返回的位置;
}/ **
*
* @参数位置
* 那个地点
* /
@JsonProperty(位置)
公共无效的setLocation(地点){
this.location =位置;
}@JsonAnyGetter
公共地图<弦乐,对象> getAdditionalProperties(){
返回this.additionalProperties;
}@JsonAnySetter
公共无效setAdditionalProperty(字符串名称,对象的值){
this.additionalProperties.put(名称,值);
}}

您rootElement的类

 进口的java.util.ArrayList;
进口的java.util.HashMap;
进口的java.util.List;
进口的java.util.Map;
进口javax.annotation.Generated;
进口com.fasterxml.jackson.annotation.JsonAnyGetter;
进口com.fasterxml.jackson.annotation.JsonAnySetter;
进口com.fasterxml.jackson.annotation.JsonIgnore;
进口com.fasterxml.jackson.annotation.JsonInclude;
进口com.fasterxml.jackson.annotation.JsonProperty;
进口com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
日期,
概要,
段,
caloriesIdle
最后更新
})
公共类rootElement的{@JsonProperty(DATE)
私人字符串日期;
@JsonProperty(摘要)
私人列表<总结>总结=新的ArrayList<总结>();
@JsonProperty(段)
私人列表<段>段=新的ArrayList&所述;段>();
@JsonProperty(caloriesIdle)
私人整数caloriesIdle;
@JsonProperty(LASTUPDATE)
私人字符串LASTUPDATE;
@JsonIgnore
私人地图<弦乐,对象> additionalProperties =新的HashMap<弦乐,对象>();/ **
*
* @返回
* 日期
* /
@JsonProperty(DATE)
公共字符串GETDATE(){
归期;
}/ **
*
* @参数日期
* 日期
* /
@JsonProperty(DATE)
公共无效的setDate(字符串日期){
this.date =日期;
}/ **
*
* @返回
* 摘要
* /
@JsonProperty(摘要)
公开名单<总结> getSummary(){
返回总结;
}/ **
*
* @参数汇总
* 摘要
* /
@JsonProperty(摘要)
公共无效setSummary(列表<总结>摘要){
this.summary =摘要;
}/ **
*
* @返回
*本段
* /
@JsonProperty(段)
公开名单<段> getSegments(){
返回段;
}/ **
*
* @参数段
*本段
* /
@JsonProperty(段)
公共无效setSegments(列表<段>段){
this.segments =段;
}/ **
*
* @返回
*本caloriesIdle
* /
@JsonProperty(caloriesIdle)
公共整数getCaloriesIdle(){
返回caloriesIdle;
}/ **
*
* @参数caloriesIdle
*本caloriesIdle
* /
@JsonProperty(caloriesIdle)
公共无效setCaloriesIdle(整数caloriesIdle){
this.caloriesIdle = caloriesIdle;
}/ **
*
* @返回
*本LASTUPDATE
* /
@JsonProperty(LASTUPDATE)
公共字符串getLastUpdate(){
返回LASTUPDATE;
}/ **
*
* @参数LASTUPDATE
*本LASTUPDATE
* /
@JsonProperty(LASTUPDATE)
公共无效setLastUpdate(字符串LASTUPDATE){
this.lastUpdate = LASTUPDATE;
}@JsonAnyGetter
公共地图<弦乐,对象> getAdditionalProperties(){
返回this.additionalProperties;
}@JsonAnySetter
公共无效setAdditionalProperty(字符串名称,对象的值){
this.additionalProperties.put(名称,值);
}}

您分部类

 进口的java.util.ArrayList;
进口的java.util.HashMap;
进口的java.util.List;
进口的java.util.Map;
进口javax.annotation.Generated;
进口com.fasterxml.jackson.annotation.JsonAnyGetter;
进口com.fasterxml.jackson.annotation.JsonAnySetter;
进口com.fasterxml.jackson.annotation.JsonIgnore;
进口com.fasterxml.jackson.annotation.JsonInclude;
进口com.fasterxml.jackson.annotation.JsonProperty;
进口com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
类型,
开始时间,
时间结束,
地点,
最后更新,
活动
})
公共类段{@JsonProperty(类型)
私人字符串类型;
@JsonProperty(startTime时)
私人字符串的startTime;
@JsonProperty(结束时间)
私人字符串结束时间;
@JsonProperty(地点)
私人地方进行;
@JsonProperty(LASTUPDATE)
私人字符串LASTUPDATE;
@JsonProperty(活动)
私人列表<活性GT;活动=新的ArrayList<活性GT;();
@JsonIgnore
私人地图<弦乐,对象> additionalProperties =新的HashMap<弦乐,对象>();/ **
*
* @返回
* 方式
* /
@JsonProperty(类型)
公共字符串的getType(){
返回类型;
}/ **
*
* @参数类型
* 方式
* /
@JsonProperty(类型)
公共无效的setType(字符串类型){
this.type =类型;
}/ **
*
* @返回
*于starttime
* /
@JsonProperty(startTime时)
公共字符串getStartTime(){
返回的startTime;
}/ **
*
* @参数的startTime
*于starttime
* /
@JsonProperty(startTime时)
公共无效setStartTime(字符串的startTime){
this.startTime = startTime;
}/ **
*
* @返回
* The endTime
* /
@JsonProperty(\"endTime\")
public String getEndTime() {
return endTime;
}/ **
*
* @param endTime
* The endTime
* /
@JsonProperty(\"endTime\")
public void setEndTime(String endTime) {
this.endTime = endTime;
}/ **
*
* @返回
* The place
* /
@JsonProperty(\"place\")
public Place getPlace() {
return place;
}/ **
*
* @param place
* The place
* /
@JsonProperty(\"place\")
public void setPlace(Place place) {
this.place = place;
}/ **
*
* @返回
* The lastUpdate
* /
@JsonProperty(\"lastUpdate\")
public String getLastUpdate() {
return lastUpdate;
}/ **
*
* @param lastUpdate
* The lastUpdate
* /
@JsonProperty(\"lastUpdate\")
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}/ **
*
* @返回
* The activities
* /
@JsonProperty(\"activities\")
public List<Activity> getActivities() {
return activities;
}/ **
*
* @param activities
* The activities
* /
@JsonProperty(\"activities\")
public void setActivities(List<Activity> activities) {
this.activities = activities;
}@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}}

Your Summary Class

<$p$p><$c$c>import java.util.HashMap;
进口的java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
活动,
\"group\",
\"duration\",
\"distance\",
\"steps\",
\"calories\"
})
public class Summary {@JsonProperty(\"activity\")
私人字符串的活动;
@JsonProperty(\"group\")
private String group;
@JsonProperty(\"duration\")
private Integer duration;
@JsonProperty(\"distance\")
private Integer distance;
@JsonProperty(\"steps\")
private Integer steps;
@JsonProperty(\"calories\")
private Integer calories;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();/ **
*
* @返回
* The activity
* /
@JsonProperty(\"activity\")
public String getActivity() {
return activity;
}/ **
*
* @param activity
* The activity
* /
@JsonProperty(\"activity\")
public void setActivity(String activity) {
this.activity =活动;
}/ **
*
* @返回
* The group
* /
@JsonProperty(\"group\")
public String getGroup() {
return group;
}/ **
*
* @param group
* The group
* /
@JsonProperty(\"group\")
public void setGroup(String group) {
this.group = group;
}/ **
*
* @返回
* The duration
* /
@JsonProperty(\"duration\")
public Integer getDuration() {
return duration;
}/ **
*
* @param duration
* The duration
* /
@JsonProperty(\"duration\")
public void setDuration(Integer duration) {
this.duration = duration;
}/ **
*
* @返回
* The distance
* /
@JsonProperty(\"distance\")
public Integer getDistance() {
return distance;
}/ **
*
* @param distance
* The distance
* /
@JsonProperty(\"distance\")
public void setDistance(Integer distance) {
this.distance = distance;
}/ **
*
* @返回
* The steps
* /
@JsonProperty(\"steps\")
public Integer getSteps() {
return steps;
}/ **
*
* @param steps
* The steps
* /
@JsonProperty(\"steps\")
public void setSteps(Integer steps) {
this.steps = steps;
}/ **
*
* @返回
* The calories
* /
@JsonProperty(\"calories\")
public Integer getCalories() {
return calories;
}/ **
*
* @param calories
* The calories
* /
@JsonProperty(\"calories\")
public void setCalories(Integer calories) {
this.calories = calories;
}@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}}

Hi I am new to Java and android and I'm trying to parse data from linked classes but I can not work out how to retrieve jsonObjects from some of the inner/nested JSONArrays?

I can retrieve objects from the outer JSONArray's but I can not see how to retrieve the nested JSONArray list objects from segments inner JSONArrays within the StorlineData class.

When I try to parse data from the inner/nested JSONArrays the response looks like this:

Thanks in advance for your help.

JSON (I am unable to get data from trackPointsData and PlacesData)

[
    {
        "date": "20121212",
        "summary": [
            {
                "activity": "walking",
                "group": "walking",
                "duration": 3333,
                "distance": 3333,
                "steps": 3333,
                "calories": 300
            },



        ],
        "segments": [
            {
                "type": "place",
                "startTime": "20121212T000000+0200",
                "endTime": "20121212T071430+0200",
                "place": {
                    "id": 1,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "move",
                "startTime": "20121212T071430+0200",
                "endTime": "20121212T074617+0200",
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T071430+0200",
                        "endTime": "20121212T072732+0200",
                        "duration": 782,
                        "distance": 1251,
                        "steps": 1353,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T071430+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T072732+0200"
                            }
                        ]
                    },
                    {
                        "activity": "transport",
                        "group": "transport",
                        "manual": false,
                        "startTime": "20121212T072732+0200",
                        "endTime": "20121212T074616+0200",
                        "duration": 1124,
                        "distance": 8443,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T072732+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T074208+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T074617+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T074617+0200",
                "endTime": "20121212T100051+0200",
                "place": {
                    "id": 2,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "walking_on_treadmill",
                        "group": "walking",
                        "manual": true,
                        "duration": 270,
                        "steps": 303,
                        "calories": 30,
                        "trackPoints": []
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },

            {
                "type": "place",
                "startTime": "20121212T100715+0200",
                "endTime": "20121212T110530+0200",
                "place": {
                    "id": 4,
                    "name": "test",
                    "type": "foursquare",
                    "foursquareId": "4df0fdb17d8ba370a011d24c",
                    "foursquareCategoryIds": ["4bf58dd8d48988d125941735"],
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T101215+0200",
                        "endTime": "20121212T101255+0200",
                        "duration": 40,
                        "distance": 18,
                        "steps": 37,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T101215+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T101255+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "move",
                "startTime": "20121212T110530+0200",
                "endTime": "20121212T111129+0200",
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T110530+0200",
                        "endTime": "20121212T111128+0200",
                        "duration": 358,
                        "distance": 493,
                        "steps": 441,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110531+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110536+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110947+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T111017+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T111129+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T111129+0200",
                "endTime": "20121212T153638+0200",
                "place": {
                    "id": 2,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "zumba",
                        "manual": true,
                        "duration": 570,
                        "calories": 200,
                        "trackPoints": []
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },

            {
                "type": "place",
                "startTime": "20121212T160744+0200",
                "endTime": "20121212T232730+0200",
                "place": {
                    "id": 1,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "lastUpdate": "20130317T121143Z"
            }
        ],
        "caloriesIdle": 1785,
        "lastUpdate": "20130317T121143Z"
    }
]

Main Activity:

...
    private MovesHandler<ArrayList<StorylineData>> storylineHandler = new MovesHandler<ArrayList<StorylineData>>() {
                @Override
                public void onSuccess(ArrayList<StorylineData> result) {
                    toggleProgress(false);
                    updateResponse(
...
                                + "-----------Segment 1-------\t"
                                + "StartTime:\t" + result.get(0).getSegments().get(0).getStartTime() + "\n"
                                + "             -Activities Array-\t" + "\n"
                                + "- StartTime:\t" +

 ...

                        + "-----------Segment 2-------\t" + "\n"
                        + "- TrackPoints :\t" + result.get(0).getTrackPoints()+ "\n"//====Array Add
                        + "- FoursquareId:\t" + result.get(0).getFoursquareId() + "\n"
                        + "- ACt:\t" + result.get(0).getActivities()+ "\n"
                            + "- Foursquare Id:\t" + result.get(0).getSegments().get(0).getPlace().getFoursquareId() + "\n"
                            + "- Foursquare Id:\t" + result.get(0).getFoursquareId() + "\n"
                            + "- Foursquare Category Ids:\t" + result.get(0).getSegments().get(0).getPlace().getFoursquareCategoryIds()+ "\n"
                            + "- Activities:\t" + result.get(0).getSegments().get(0).getActivities()+ "\n"
);

        }

...

StorylineData Class (I would like to retrieve jsonObjects from inner JSONArrays here in the storylineData class):

/**
 * Parse a {@link org.json.JSONObject} from storyline {@link org.json.JSONArray}, then return the corresponding {@link StorylineData} object.
 *
 * @param jsonObject : the storyline JSON object received from server
 * @return corresponding {@link StorylineData}
 */
public static StorylineData parse(JSONObject jsonObject) throws JSONException {
    if (jsonObject != null) {

        StorylineData storylineData = new StorylineData();

        storylineData.date = jsonObject.optString("date");
        storylineData.caloriesIdle = jsonObject.optInt("caloriesIdle");
        storylineData.lastUpdate = jsonObject.optString("lastUpdate");
        storylineData.summary = new ArrayList<>();
        storylineData.segments = new ArrayList<>();

        JSONArray summariesJsonArray = jsonObject.optJSONArray("summary");

        if (summariesJsonArray != null)
        for (int i = 0; i < summariesJsonArray.length(); i++) {

            JSONObject summaryJsonObject = summariesJsonArray.optJSONObject(i);

                    if (summaryJsonObject != null) {
                    summariesJsonArray.getJSONObject(i).getString("distance");

                        String group = summaryJsonObject.optString("group");

                        Integer distance = summaryJsonObject.optInt("distance");
                        storylineData.setDistance(distance);
...
                    storylineData.summary.add(SummaryData.parse(summaryJsonObject));

                        Log.d("StorylineDataCls \t sJo", summaryJsonObject.toString() + "Log\n");
                        System.out.println("print distance" + summariesJsonArray.getJSONObject(i).getString("distance"));       
                        System.out.println("print summary" + summaryJsonObject);

                }
            }

        JSONArray segmentsJsonArray = jsonObject.optJSONArray("segments");
        if (segmentsJsonArray != null) {

            for (int i = 0; i < segmentsJsonArray.length(); i++) {
                JSONObject segment = segmentsJsonArray.optJSONObject(i);

                if (segment != null) {

                    JSONArray activitiesJsonArray = segment.optJSONArray("activities");
                    if (activitiesJsonArray!=null) {

                        for (int j = 0; j < activitiesJsonArray.length(); j++) {
                            JSONObject trackPoints = activitiesJsonArray.optJSONObject(j);
                            if(trackPoints != null){
                        ...
                    storylineData.trackPoints.add(TrackPointsData.parse(trackPoints));
                                 }
                        }
                    }

            ..
                    Log.d("StorylineDataCls \t sSo", segment.toString());
                    System.out.println("print segment" + segment);
                    //System.out.println("print segments" + segments);
                    System.out.println("print segmentsJsonArray" + segmentsJsonArray);

                }
            }
        }


        return storylineData;
    }
    return null;


}

============PARSER METHODS IN LINKED CLASSES================

PlaceData Class:

/**
     * Parse a {@link org.json.JSONObject} of place, then return the corresponding {@link PlaceData} object.
     * @param jsonObject : the 'place' JSON object to parse
     * @return corresponding {@link PlaceData}
     */
    public static PlaceData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
            PlaceData placeData = new PlaceData();

        placeData.id            = jsonObject.optString("id");
        placeData.name          = jsonObject.optString("name");
        placeData.type          = jsonObject.optString("type");
        placeData.foursquareId  = jsonObject.optString("foursquareId");

        JSONObject location = jsonObject.optJSONObject("location");
        if (location != null) {
            placeData.location = LocationData.parse(location);
        }

        JSONArray trackPointsJSONArray      = jsonObject.optJSONArray("foursquareCategoryIds");
        placeData.foursquareCategoryIds = new ArrayList<String>();
        if (trackPointsJSONArray != null) {
            for (int i = 0; i < trackPointsJSONArray.length(); i++) {
                String categoryId  = trackPointsJSONArray.optString(i);
                if (categoryId != null && categoryId.length() > 0) {

                    placeData.foursquareCategoryIds.add(categoryId);
                }
            }
        }


        return placeData;
    }
    return null;
}

}

LocationData Class:

/**
     * Parse a {@link org.json.JSONObject} from trackPoints {@link org.json.JSONArray}, then return the corresponding
     * {@link LocationData} object.
     * @param jsonObject : the 'trackPoint' JSON object to parse
     * @return corresponding {@link LocationData}
     */
    public static LocationData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
                LocationData trackPointsData = new LocationData();
                trackPointsData.lat     = jsonObject.optString("lat");
                trackPointsData.lon     = jsonObject.optString("lon");


            return trackPointsData;
        }
        return null;
    }

}

TrackPointData Class:

/**
 * Parse a {@link org.json.JSONObject} from trackPoints {@link org.json.JSONArray}, then return the corresponding
 * {@link TrackPointsData} object.
 * @param jsonObject : the 'trackPoint' JSON object to parse
 * @return corresponding {@link TrackPointsData}
 */
public static TrackPointsData parse(JSONObject jsonObject) {
    if (jsonObject != null) {
            TrackPointsData trackPointsData = new TrackPointsData();
            trackPointsData.lat     = jsonObject.optString("lat");
            trackPointsData.lon     = jsonObject.optString("lon");
            trackPointsData.time    = jsonObject.optString("time");


            return trackPointsData;
    }
    return null;
}

}

ActivityData Class:

/**
     * Parse a {@link org.json.JSONObject} from activities {@link org.json.JSONArray}, then return the corresponding
     * {@link ActivityData} object.
     * @param jsonObject : the 'activity' JSON object to parse
     * @return corresponding {@link ActivityData}
     */
    public static ActivityData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
            ActivityData activityData = new ActivityData();
                activityData.activity       = jsonObject.optString("activity");
                activityData.group          = jsonObject.optString("group");
                activityData.manual         = jsonObject.optString("manual");
                activityData.startTime      = jsonObject.optString("startTime");
                activityData.endTime        = jsonObject.optString("endTime");
                activityData.duration       = jsonObject.optInt("duration");
                activityData.distance       = jsonObject.optInt("distance");
                activityData.steps          = jsonObject.optInt("steps");
                activityData.calories       = jsonObject.optInt("calories");
            JSONArray trackPointsJSONArray      = jsonObject.optJSONArray("trackPoints");

                activityData.trackPoints = new ArrayList<TrackPointsData>();
                if (trackPointsJSONArray != null) {
                    for (int i = 0; i < trackPointsJSONArray.length(); i++) {
                        JSONObject summaryJsonObject = trackPointsJSONArray.optJSONObject(i);
                        if (summaryJsonObject != null) {



                            activityData.trackPoints.add(TrackPointsData.parse(summaryJsonObject));


                        }
                    }
                }



                return activityData;
        }
        return null;


    }


}

SegmentData Class:

/**
     * Parse a {@link org.json.JSONObject} from segments {@link org.json.JSONArray}, then return the corresponding {@link SegmentData} object.
     * @param jsonObject : the 'segment' JSON object to parse
     * @return corresponding {@link SegmentData}
     */
    public static SegmentData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
            SegmentData segmentData = new SegmentData();
            segmentData.type        = jsonObject.optString("type");
            segmentData.startTime   = jsonObject.optString("startTime");
            segmentData.endTime     = jsonObject.optString("endTime");
            segmentData.lastUpdate  = jsonObject.optString("lastUpdate");
            segmentData.name    = jsonObject.optString("name");

            JSONArray activitiesJSONArray = jsonObject.optJSONArray("activities");
            segmentData.activities = new ArrayList<ActivityData>();
            if (activitiesJSONArray != null) {
                for (int i = 0; i < activitiesJSONArray.length(); i++) {
                    JSONObject activityJsonObject = activitiesJSONArray.optJSONObject(i);
                    if (activityJsonObject != null) {


                        placeData = (PlaceData) activityJsonObject.opt(String.valueOf(placeData));
                        segmentData.setPlace(placeData);



                        segmentData.activities.add(ActivityData.parse(activityJsonObject));
                    }
                }
            }

            JSONObject placeJsonObject = jsonObject.optJSONObject("place");
            if (placeJsonObject != null) {
                segmentData.place = PlaceData.parse(placeJsonObject);
            }

            return segmentData;
        }
        return null;
    }
}

SummaryData Class:

/**
     * Parse a {@link org.json.JSONObject} from summary {@link org.json.JSONArray}, then return the corresponding {@link SummaryData} object.
     * @param jsonObject : the 'summary' JSON object to parse
     * @return corresponding {@link SummaryData}
     */
    public static SummaryData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
                SummaryData summary = new SummaryData();
                summary.activity        = jsonObject.optString("activity");
                summary.group           = jsonObject.optString("group");
                summary.duration        = jsonObject.optInt("duration");
                summary.distance        = jsonObject.optInt("distance");
                summary.steps           = jsonObject.optInt("steps");
                summary.calories        = jsonObject.optInt("calories");

            //Log.d("json", summary.toString());



            return summary;
        }
        return null;
    }
}

HTTPCall Class:...

    public static void getDailyStorylineList(final MovesHandler<ArrayList<StorylineData>> handler,
                                             final String specificSummary,
                                             final String from,
                                             final String to,
                                             final String pastDays,
                                             final String updatedSince,
                                             final boolean needTrackPoints) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    /* Refresh access token if only AuthData.MOVES_REFRESHBEFORE days are there to expire current token */
                    AuthData.refreshAccessTokenIfNeeded();

                    /* Exchange the authorization code we obtained after login to get access token */
                    HashMap<String, String> nameValuePairs = new HashMap<String, String>();
                    nameValuePairs.put("access_token", AuthData.getAuthData().getAccessToken());

                   // if (specificSummary != null && specificSummary.length() > 0) nameValuePairs.put("specificSummary", specificSummary);//att

                    if (from != null && from.length() > 0) nameValuePairs.put("from", from);
                    if (to != null && to.length() > 0) nameValuePairs.put("to", to);
                    if (pastDays != null && pastDays.length() > 0) nameValuePairs.put("pastDays", pastDays);
                    if (updatedSince != null && updatedSince.length() > 0) nameValuePairs.put("updatedSince", updatedSince);
                    if (needTrackPoints) nameValuePairs.put("trackPoints", "true");


                    URL url     = new URL(MovesAPI.API_BASE + MovesAPI.API_PATH_STORYLINE + (specificSummary != null ? specificSummary : "") + "?" + Utilities.encodeUrl(nameValuePairs));
                    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
                    urlConnection.setRequestMethod("GET");
                    urlConnection.setDoInput(true);
                    urlConnection.connect();

                    if (urlConnection.getResponseCode() != 200) {
                        /* All other HTTP errors from Moves will fall here */
                        handler.onFailure(getErrorStatus(Utilities.readStream(urlConnection.getErrorStream()), urlConnection.getResponseCode()), "Server not responded with success ("+ urlConnection.getResponseCode() +")");
                        return;
                    }

                    String response = Utilities.readStream(urlConnection.getInputStream());
                    Object object = new JSONTokener(response).nextValue();
                    if (object instanceof JSONArray) {
                        JSONArray jsonArray = (JSONArray) object;
                        ArrayList<StorylineData> storylineData = new ArrayList<StorylineData>();
                        if (jsonArray != null) {
                            for (int i = 0; i < jsonArray.length(); i++) {
                                JSONObject storylineJsonObject = jsonArray.optJSONObject(i);
                                if (storylineJsonObject != null) {
                                    storylineData.add(StorylineData.parse(storylineJsonObject));
                                }
                            }
                        }
                        handler.onSuccess(storylineData);
                    } else {
                        handler.onFailure(MovesStatus.INVALID_RESPONSE, "Expected a JSONArray from server, but failed");
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                    handler.onFailure(MovesStatus.UNEXPECTED_ERROR, "An unexpected error occured, please check logcat");
                }
            }
        }).start();
    }

MovesHandler Class

/**
 * This interface will act as a handler who notifies all success and failures
 * 
 *
 * @param <T> : A generic class, which probably will be the response type after success
 * @see MovesStatus
 */
public interface MovesHandler<T> {//T stands for generic type

    /**
     * Implement this method to get success notifications along with the result
     * @param result : Result of the operation completed with this handler
     */
    public void onSuccess(T result);

    /**
     * Implement this method to get failure notifications along with the {@link MovesStatus} code and a brief message
     * @param status : Status code of the failure
     * @param message : A brief message about the reason behind failure
     */
    public void onFailure(MovesStatus status, String message);
}

MovesAPI Class

 /**
     * Get daily storylines for user.
     * @see <a href="https://dev.moves-app.com/docs/api_storyline">Moves Developer Page for Daily Storyline</a>
     * @see SummaryListData
     * @param handler : An implemented {@link MovesHandler} with an {@link ArrayList} of {@link StorylineData}.
     * This handler will get notified when the request completes.
     * @param date : date in yyyyMMdd or yyyy-MM-dd format
     * @param updatedSince : [optional] if set, return only days which data has been updated since
     * given time stamp in ISO 8601 (yyyyMMdd’T’HHmmssZ) format, pass <code>null</code> if not required.
     * @param needTrackPoints : if true, the returned activities also include {@link TrackPointsData} information.
     * Including track points limits the query range to 7 days.
     */
    public static void getStoryline_SingleDay(MovesHandler<ArrayList<StorylineData>> handler, String date, String updatedSince, boolean needTrackPoints) {
        if (AuthData.isAuthenticated()) {
            HTTPCall.getDailyStorylineList(handler, "/" + date, null, null, null, updatedSince, needTrackPoints);
        } else {
            handler.onFailure(MovesStatus.NOT_AUTHENTICATED, "You are not yet authenticated with required scopes!");
        }
    }

SummaryListData Class:

public static SummaryListData parse(JSONObject jsonObject) {
        if (jsonObject != null) {
                SummaryListData summary = new SummaryListData();

                summary.date            = jsonObject.optString("date");
                summary.caloriesIdle    = jsonObject.optString("caloriesIdle");
                summary.lastUpdate      = jsonObject.optString("lastUpdate");
                summary.summaries       = new ArrayList<SummaryData>();

                JSONArray summariesJsonArray= jsonObject.optJSONArray("summary");
                if (summariesJsonArray != null) {
                    for (int i = 0; i < summariesJsonArray.length(); i++) {
                        JSONObject summaryJsonObject = summariesJsonArray.optJSONObject(i);
                        if (summaryJsonObject != null) {
                            summary.summaries.add(SummaryData.parse(summaryJsonObject));

                            Log.d("summaryHandler", summaryJsonObject.toString());


                        }
                    }
                }

                return summary;
        }
        return null;
    }


}
解决方案

this is your valid json response

[
    {
        "date": "20121212",
        "summary": [
            {
                "activity": "walking",
                "group": "walking",
                "duration": 3333,
                "distance": 3333,
                "steps": 3333,
                "calories": 300
            }
        ],
        "segments": [
            {
                "type": "place",
                "startTime": "20121212T000000+0200",
                "endTime": "20121212T071430+0200",
                "place": {
                    "id": 1,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "move",
                "startTime": "20121212T071430+0200",
                "endTime": "20121212T074617+0200",
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T071430+0200",
                        "endTime": "20121212T072732+0200",
                        "duration": 782,
                        "distance": 1251,
                        "steps": 1353,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T071430+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T072732+0200"
                            }
                        ]
                    },
                    {
                        "activity": "transport",
                        "group": "transport",
                        "manual": false,
                        "startTime": "20121212T072732+0200",
                        "endTime": "20121212T074616+0200",
                        "duration": 1124,
                        "distance": 8443,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T072732+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T074208+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T074617+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T074617+0200",
                "endTime": "20121212T100051+0200",
                "place": {
                    "id": 2,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "walking_on_treadmill",
                        "group": "walking",
                        "manual": true,
                        "duration": 270,
                        "steps": 303,
                        "calories": 30,
                        "trackPoints": []
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T100715+0200",
                "endTime": "20121212T110530+0200",
                "place": {
                    "id": 4,
                    "name": "test",
                    "type": "foursquare",
                    "foursquareId": "4df0fdb17d8ba370a011d24c",
                    "foursquareCategoryIds": [
                        "4bf58dd8d48988d125941735"
                    ],
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T101215+0200",
                        "endTime": "20121212T101255+0200",
                        "duration": 40,
                        "distance": 18,
                        "steps": 37,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T101215+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T101255+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "move",
                "startTime": "20121212T110530+0200",
                "endTime": "20121212T111129+0200",
                "activities": [
                    {
                        "activity": "walking",
                        "group": "walking",
                        "manual": false,
                        "startTime": "20121212T110530+0200",
                        "endTime": "20121212T111128+0200",
                        "duration": 358,
                        "distance": 493,
                        "steps": 441,
                        "calories": 99,
                        "trackPoints": [
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110531+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110536+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T110947+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T111017+0200"
                            },
                            {
                                "lat": 55.55555,
                                "lon": 33.33333,
                                "time": "20121212T111129+0200"
                            }
                        ]
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T111129+0200",
                "endTime": "20121212T153638+0200",
                "place": {
                    "id": 2,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "activities": [
                    {
                        "activity": "zumba",
                        "manual": true,
                        "duration": 570,
                        "calories": 200,
                        "trackPoints": []
                    }
                ],
                "lastUpdate": "20130317T121143Z"
            },
            {
                "type": "place",
                "startTime": "20121212T160744+0200",
                "endTime": "20121212T232730+0200",
                "place": {
                    "id": 1,
                    "type": "unknown",
                    "location": {
                        "lat": 55.55555,
                        "lon": 33.33333
                    }
                },
                "lastUpdate": "20130317T121143Z"
            }
        ],
        "caloriesIdle": 1785,
        "lastUpdate": "20130317T121143Z"
    }
]

And this are your POJO classes accordingly

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"activity",
"manual",
"duration",
"calories",
"trackPoints"
})
public class Activity {

@JsonProperty("activity")
private String activity;
@JsonProperty("manual")
private Boolean manual;
@JsonProperty("duration")
private Integer duration;
@JsonProperty("calories")
private Integer calories;
@JsonProperty("trackPoints")
private List<Object> trackPoints = new ArrayList<Object>();
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The activity
*/
@JsonProperty("activity")
public String getActivity() {
return activity;
}

/**
* 
* @param activity
* The activity
*/
@JsonProperty("activity")
public void setActivity(String activity) {
this.activity = activity;
}

/**
* 
* @return
* The manual
*/
@JsonProperty("manual")
public Boolean getManual() {
return manual;
}

/**
* 
* @param manual
* The manual
*/
@JsonProperty("manual")
public void setManual(Boolean manual) {
this.manual = manual;
}

/**
* 
* @return
* The duration
*/
@JsonProperty("duration")
public Integer getDuration() {
return duration;
}

/**
* 
* @param duration
* The duration
*/
@JsonProperty("duration")
public void setDuration(Integer duration) {
this.duration = duration;
}

/**
* 
* @return
* The calories
*/
@JsonProperty("calories")
public Integer getCalories() {
return calories;
}

/**
* 
* @param calories
* The calories
*/
@JsonProperty("calories")
public void setCalories(Integer calories) {
this.calories = calories;
}

/**
* 
* @return
* The trackPoints
*/
@JsonProperty("trackPoints")
public List<Object> getTrackPoints() {
return trackPoints;
}

/**
* 
* @param trackPoints
* The trackPoints
*/
@JsonProperty("trackPoints")
public void setTrackPoints(List<Object> trackPoints) {
this.trackPoints = trackPoints;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

your location class

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"lat",
"lon"
})
public class Location {

@JsonProperty("lat")
private Double lat;
@JsonProperty("lon")
private Double lon;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The lat
*/
@JsonProperty("lat")
public Double getLat() {
return lat;
}

/**
* 
* @param lat
* The lat
*/
@JsonProperty("lat")
public void setLat(Double lat) {
this.lat = lat;
}

/**
* 
* @return
* The lon
*/
@JsonProperty("lon")
public Double getLon() {
return lon;
}

/**
* 
* @param lon
* The lon
*/
@JsonProperty("lon")
public void setLon(Double lon) {
this.lon = lon;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

Your Place class

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"id",
"type",
"location"
})
public class Place {

@JsonProperty("id")
private Integer id;
@JsonProperty("type")
private String type;
@JsonProperty("location")
private Location location;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The id
*/
@JsonProperty("id")
public Integer getId() {
return id;
}

/**
* 
* @param id
* The id
*/
@JsonProperty("id")
public void setId(Integer id) {
this.id = id;
}

/**
* 
* @return
* The type
*/
@JsonProperty("type")
public String getType() {
return type;
}

/**
* 
* @param type
* The type
*/
@JsonProperty("type")
public void setType(String type) {
this.type = type;
}

/**
* 
* @return
* The location
*/
@JsonProperty("location")
public Location getLocation() {
return location;
}

/**
* 
* @param location
* The location
*/
@JsonProperty("location")
public void setLocation(Location location) {
this.location = location;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

Your RootElement class

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"date",
"summary",
"segments",
"caloriesIdle",
"lastUpdate"
})
public class RootElement {

@JsonProperty("date")
private String date;
@JsonProperty("summary")
private List<Summary> summary = new ArrayList<Summary>();
@JsonProperty("segments")
private List<Segment> segments = new ArrayList<Segment>();
@JsonProperty("caloriesIdle")
private Integer caloriesIdle;
@JsonProperty("lastUpdate")
private String lastUpdate;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The date
*/
@JsonProperty("date")
public String getDate() {
return date;
}

/**
* 
* @param date
* The date
*/
@JsonProperty("date")
public void setDate(String date) {
this.date = date;
}

/**
* 
* @return
* The summary
*/
@JsonProperty("summary")
public List<Summary> getSummary() {
return summary;
}

/**
* 
* @param summary
* The summary
*/
@JsonProperty("summary")
public void setSummary(List<Summary> summary) {
this.summary = summary;
}

/**
* 
* @return
* The segments
*/
@JsonProperty("segments")
public List<Segment> getSegments() {
return segments;
}

/**
* 
* @param segments
* The segments
*/
@JsonProperty("segments")
public void setSegments(List<Segment> segments) {
this.segments = segments;
}

/**
* 
* @return
* The caloriesIdle
*/
@JsonProperty("caloriesIdle")
public Integer getCaloriesIdle() {
return caloriesIdle;
}

/**
* 
* @param caloriesIdle
* The caloriesIdle
*/
@JsonProperty("caloriesIdle")
public void setCaloriesIdle(Integer caloriesIdle) {
this.caloriesIdle = caloriesIdle;
}

/**
* 
* @return
* The lastUpdate
*/
@JsonProperty("lastUpdate")
public String getLastUpdate() {
return lastUpdate;
}

/**
* 
* @param lastUpdate
* The lastUpdate
*/
@JsonProperty("lastUpdate")
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

Your Segment class

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"type",
"startTime",
"endTime",
"place",
"lastUpdate",
"activities"
})
public class Segment {

@JsonProperty("type")
private String type;
@JsonProperty("startTime")
private String startTime;
@JsonProperty("endTime")
private String endTime;
@JsonProperty("place")
private Place place;
@JsonProperty("lastUpdate")
private String lastUpdate;
@JsonProperty("activities")
private List<Activity> activities = new ArrayList<Activity>();
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The type
*/
@JsonProperty("type")
public String getType() {
return type;
}

/**
* 
* @param type
* The type
*/
@JsonProperty("type")
public void setType(String type) {
this.type = type;
}

/**
* 
* @return
* The startTime
*/
@JsonProperty("startTime")
public String getStartTime() {
return startTime;
}

/**
* 
* @param startTime
* The startTime
*/
@JsonProperty("startTime")
public void setStartTime(String startTime) {
this.startTime = startTime;
}

/**
* 
* @return
* The endTime
*/
@JsonProperty("endTime")
public String getEndTime() {
return endTime;
}

/**
* 
* @param endTime
* The endTime
*/
@JsonProperty("endTime")
public void setEndTime(String endTime) {
this.endTime = endTime;
}

/**
* 
* @return
* The place
*/
@JsonProperty("place")
public Place getPlace() {
return place;
}

/**
* 
* @param place
* The place
*/
@JsonProperty("place")
public void setPlace(Place place) {
this.place = place;
}

/**
* 
* @return
* The lastUpdate
*/
@JsonProperty("lastUpdate")
public String getLastUpdate() {
return lastUpdate;
}

/**
* 
* @param lastUpdate
* The lastUpdate
*/
@JsonProperty("lastUpdate")
public void setLastUpdate(String lastUpdate) {
this.lastUpdate = lastUpdate;
}

/**
* 
* @return
* The activities
*/
@JsonProperty("activities")
public List<Activity> getActivities() {
return activities;
}

/**
* 
* @param activities
* The activities
*/
@JsonProperty("activities")
public void setActivities(List<Activity> activities) {
this.activities = activities;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

Your Summary Class

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"activity",
"group",
"duration",
"distance",
"steps",
"calories"
})
public class Summary {

@JsonProperty("activity")
private String activity;
@JsonProperty("group")
private String group;
@JsonProperty("duration")
private Integer duration;
@JsonProperty("distance")
private Integer distance;
@JsonProperty("steps")
private Integer steps;
@JsonProperty("calories")
private Integer calories;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
* 
* @return
* The activity
*/
@JsonProperty("activity")
public String getActivity() {
return activity;
}

/**
* 
* @param activity
* The activity
*/
@JsonProperty("activity")
public void setActivity(String activity) {
this.activity = activity;
}

/**
* 
* @return
* The group
*/
@JsonProperty("group")
public String getGroup() {
return group;
}

/**
* 
* @param group
* The group
*/
@JsonProperty("group")
public void setGroup(String group) {
this.group = group;
}

/**
* 
* @return
* The duration
*/
@JsonProperty("duration")
public Integer getDuration() {
return duration;
}

/**
* 
* @param duration
* The duration
*/
@JsonProperty("duration")
public void setDuration(Integer duration) {
this.duration = duration;
}

/**
* 
* @return
* The distance
*/
@JsonProperty("distance")
public Integer getDistance() {
return distance;
}

/**
* 
* @param distance
* The distance
*/
@JsonProperty("distance")
public void setDistance(Integer distance) {
this.distance = distance;
}

/**
* 
* @return
* The steps
*/
@JsonProperty("steps")
public Integer getSteps() {
return steps;
}

/**
* 
* @param steps
* The steps
*/
@JsonProperty("steps")
public void setSteps(Integer steps) {
this.steps = steps;
}

/**
* 
* @return
* The calories
*/
@JsonProperty("calories")
public Integer getCalories() {
return calories;
}

/**
* 
* @param calories
* The calories
*/
@JsonProperty("calories")
public void setCalories(Integer calories) {
this.calories = calories;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}

这篇关于Android应用内返回数组为[]或ArrayList的内存分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 15:18