Search in sources :

Example 1 with JSONArray

use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.

the class Favorites method constructFavorites.

public static List<Favorites> constructFavorites(Response res) throws WeiboException {
    try {
        JSONArray list = res.asJSONObject().getJSONArray("favorites");
        int size = list.length();
        List<Favorites> favorites = new ArrayList<Favorites>(size);
        for (int i = 0; i < size; i++) {
            favorites.add(new Favorites(list.getJSONObject(i)));
        }
        totalNumber = res.asJSONObject().getInt("total_number");
        return favorites;
    } catch (JSONException jsone) {
        throw new WeiboException(jsone);
    }
}
Also used : JSONArray(weibo4j.org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(weibo4j.org.json.JSONException)

Example 2 with JSONArray

use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.

the class FavoritesTag method constructTag.

public static List<FavoritesTag> constructTag(Response res) throws WeiboException {
    try {
        JSONArray list = res.asJSONObject().getJSONArray("tags");
        int size = list.length();
        List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
        for (int i = 0; i < size; i++) {
            tags.add(new FavoritesTag(list.getJSONObject(i)));
        }
        return tags;
    } catch (JSONException jsone) {
        throw new WeiboException(jsone);
    } catch (WeiboException te) {
        throw te;
    }
}
Also used : JSONArray(weibo4j.org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(weibo4j.org.json.JSONException)

Example 3 with JSONArray

use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.

the class School method constructSchool.

public static List<School> constructSchool(Response res) throws WeiboException {
    try {
        JSONArray list = res.asJSONArray();
        int size = list.length();
        List<School> schools = new ArrayList<School>(size);
        for (int i = 0; i < size; i++) {
            schools.add(new School(list.getJSONObject(i)));
        }
        return schools;
    } catch (JSONException jsone) {
        throw new WeiboException(jsone);
    } catch (WeiboException te) {
        throw te;
    }
}
Also used : JSONArray(weibo4j.org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(weibo4j.org.json.JSONException)

Example 4 with JSONArray

use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.

the class Tag method constructTags.

public static List<Tag> constructTags(Response res) throws WeiboException {
    try {
        JSONArray list = res.asJSONArray();
        int size = list.length();
        List<Tag> tags = new ArrayList<Tag>(size);
        for (int i = 0; i < size; i++) {
            tags.add(new Tag(list.getJSONObject(i)));
        }
        return tags;
    } catch (JSONException jsone) {
        throw new WeiboException(jsone);
    } catch (WeiboException te) {
        throw te;
    }
}
Also used : JSONArray(weibo4j.org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(weibo4j.org.json.JSONException)

Example 5 with JSONArray

use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.

the class Tag method constructTag.

public static List<FavoritesTag> constructTag(Response res) throws WeiboException {
    try {
        JSONArray list = res.asJSONObject().getJSONArray("tags");
        int size = list.length();
        List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
        for (int i = 0; i < size; i++) {
            tags.add(new FavoritesTag(list.getJSONObject(i)));
        }
        return tags;
    } catch (JSONException jsone) {
        throw new WeiboException(jsone);
    } catch (WeiboException te) {
        throw te;
    }
}
Also used : JSONArray(weibo4j.org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(weibo4j.org.json.JSONException)

Aggregations

JSONArray (weibo4j.org.json.JSONArray)16 JSONException (weibo4j.org.json.JSONException)16 ArrayList (java.util.ArrayList)13 JSONObject (weibo4j.org.json.JSONObject)5 Date (java.util.Date)2 Iterator (java.util.Iterator)1