对比分析json及XML(11)


private ArrayList<VideoConstant> parseVideoAlbumJsonObject(JSONObject albumJSONObject,  ArrayList<Integer> albumIdJSONArrayList) {
    MyLog.d(TAG, "parseVideoAlbumJsonObject, length=" + albumJSONObject.length());
    if (albumJSONObject.length() < 1) {
        return null;
    }
    ArrayList<VideoConstant> videos = new ArrayList<VideoConstant>();
    try {
        for (int index = 0; index < albumJSONObject.length(); index++) {
            VideoConstant video = new VideoConstant();
            JSONObject itemJsonObject;
            itemJsonObject = albumJSONObject.getJSONObject(albumIdJSONArrayList.get(index)
                    .toString());
            MyLog.d(TAG, "string=" + albumIdJSONArrayList.get(index).toString());
            video.mAlbumId = itemJsonObject.optString(InterfaceParameterName.ID);
            video.mAtitle = itemJsonObject.optString(InterfaceParameterName.TITLE);
            video.mEpisodeCount = itemJsonObject.optString(InterfaceParameterName.UPDATE_SET);
            video.mTvSets = itemJsonObject.optString(InterfaceParameterName.TV_SETS);
            video.mDesc = itemJsonObject.optString(InterfaceParameterName.DESCRIPTION);
            video.mCid = itemJsonObject.optString(InterfaceParameterName.CATEGORY_ID);
            video.mImg = itemJsonObject.optString(InterfaceParameterName.IMG);
            video.mHighimg = itemJsonObject
                    .optString(InterfaceParameterName.HIGH_RESO_PORT_IMG);
            video.mHoriImg = itemJsonObject
                    .optString(InterfaceParameterName.HIGH_RESO_HORI_IMG);
            video.mScore = itemJsonObject.optString(InterfaceParameterName.SCORE);
            video.mMainActors = itemJsonObject.optString(InterfaceParameterName.MAIN_ACTOR);
            video.mCreateTime = itemJsonObject.optString(InterfaceParameterName.CREATE_TIME);
            video.mDuration = itemJsonObject.optString(InterfaceParameterName.DURATION);
            video.mTag = itemJsonObject.optString(InterfaceParameterName.TAG);
            MyLog.d(TAG, "id=" + video.mAlbumId + ",title=" + video.mAlbumTitle + ",img="
                    + video.mHighimg + ",tvsets=" + video.mTvSets);
            videos.add(video);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return videos;
}

  <4>. Android JSON解析库

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgswyx.html