龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

对比分析json及XML(13)

时间:2014-12-03 03:00来源:网络整理 作者:网络 点击:
分享到:
复制代码 代码如下: private ArrayListVideoConstant parseVideoAlbumJsonObject(JSONObject albumJSONObject, ArrayListInteger albumIdJSONArrayList) { MyLog.d(TAG, "parseVideoAlbumJsonObject, length

复制代码 代码如下:

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解析库

精彩图集

赞助商链接