Search in sources :

Example 1 with TagBean

use of org.qii.weiciyuan.bean.TagBean in project weiciyuan by qii.

the class FriendsTimeLineTagDao method getGSONMsgList.

public List<TagBean> getGSONMsgList() throws WeiboException {
    String json = getMsgListJson();
    List<TagBean> tagBeanList = new ArrayList<TagBean>();
    try {
        JSONArray array = new JSONArray(json);
        int size = array.length();
        for (int i = 0; i < size; i++) {
            TagBean bean = new TagBean();
            JSONObject jsonObject = array.getJSONObject(i);
            Iterator<String> iterator = jsonObject.keys();
            while (iterator.hasNext()) {
                String key = iterator.next();
                if (key.equalsIgnoreCase("weight")) {
                    String value = jsonObject.optString(key);
                    bean.setWeight(value);
                } else {
                    String value = jsonObject.optString(key);
                    bean.setId(Integer.valueOf(key));
                    bean.setName(value);
                }
            }
            tagBeanList.add(bean);
        }
    } catch (JSONException e) {
        AppLogger.e(e.getMessage());
    }
    return tagBeanList;
}
Also used : JSONObject(org.json.JSONObject) TagBean(org.qii.weiciyuan.bean.TagBean) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Aggregations

ArrayList (java.util.ArrayList)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 TagBean (org.qii.weiciyuan.bean.TagBean)1