当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.getJSONObject方法代码示例

本文整理汇总了Java中twitter4j.internal.org.json.JSONArray.getJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.getJSONObject方法的具体用法?Java JSONArray.getJSONObject怎么用?Java JSONArray.getJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twitter4j.internal.org.json.JSONArray的用法示例。


在下文中一共展示了JSONArray.getJSONObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getURLEntitiesFromJSON

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
/**
 * Get URL Entities from JSON Object.
 * returns URLEntity array by entities/[category]/urls/url[]
 *
 * @param json     user json object
 * @param category entities category. e.g. "description" or "url"
 * @return URLEntity array by entities/[category]/urls/url[]
 * @throws JSONException
 * @throws TwitterException
 */
private static URLEntity[] getURLEntitiesFromJSON(JSONObject json, String category) throws JSONException, TwitterException {
    if (!json.isNull("entities")) {
        JSONObject entitiesJSON = json.getJSONObject("entities");
        if (!entitiesJSON.isNull(category)) {
            JSONObject descriptionEntitiesJSON = entitiesJSON.getJSONObject(category);
            if (!descriptionEntitiesJSON.isNull("urls")) {
                JSONArray urlsArray = descriptionEntitiesJSON.getJSONArray("urls");
                int len = urlsArray.length();
                URLEntity[] urlEntities = new URLEntity[len];
                for (int i = 0; i < len; i++) {
                    urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i));
                }
                return urlEntities;
            }
        }
    }
    return null;
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:29,代码来源:UserJSONImpl.java

示例2: createUserList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<User> createUserList(JSONArray list, HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        int size = list.length();
        ResponseList<User> users = new ResponseListImpl<User>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            User user = new UserJSONImpl(json);
            users.add(user);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(user, json);
            }
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(users, list);
        }
        return users;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:26,代码来源:UserJSONImpl.java

示例3: createDirectMessageList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<DirectMessage> createDirectMessageList(HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        JSONArray list = res.asJSONArray();
        int size = list.length();
        ResponseList<DirectMessage> directMessages = new ResponseListImpl<DirectMessage>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            DirectMessage directMessage = new DirectMessageJSONImpl(json);
            directMessages.add(directMessage);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(directMessage, json);
            }
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(directMessages, list);
        }
        return directMessages;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:DirectMessageJSONImpl.java

示例4: AccountSettingsJSONImpl

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
private AccountSettingsJSONImpl(HttpResponse res, JSONObject json) throws TwitterException {
    super(res);
    try {
        JSONObject sleepTime = json.getJSONObject("sleep_time");
        SLEEP_TIME_ENABLED = getBoolean("enabled", sleepTime);
        SLEEP_START_TIME = sleepTime.getString("start_time");
        SLEEP_END_TIME = sleepTime.getString("end_time");
        if (json.isNull("trend_location")) {
            TREND_LOCATION = new Location[0];
        } else {
            JSONArray locations = json.getJSONArray("trend_location");
            TREND_LOCATION = new Location[locations.length()];
            for (int i = 0; i < locations.length(); i++) {
                TREND_LOCATION[i] = new LocationJSONImpl(locations.getJSONObject(i));
            }
        }
        GEO_ENABLED = getBoolean("geo_enabled", json);
        LANGUAGE = json.getString("language");
        ALWAYS_USE_HTTPS = getBoolean("always_use_https", json);
        DISCOVERABLE_BY_EMAIL = getBoolean("discoverable_by_email", json);
        TIMEZONE = new TimeZoneJSONImpl(json.getJSONObject("time_zone"));
    } catch (JSONException e) {
        throw new TwitterException(e);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:26,代码来源:AccountSettingsJSONImpl.java

示例5: createStatusList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
public static ResponseList<Status> createStatusList(HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        JSONArray list = res.asJSONArray();
        int size = list.length();
        ResponseList<Status> statuses = new ResponseListImpl<Status>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            Status status = new StatusJSONImpl(json);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(status, json);
            }
            statuses.add(status);
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(statuses, list);
        }
        return statuses;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:25,代码来源:StatusJSONImpl.java

示例6: parseStatuses

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
public static ResponseList<Status> parseStatuses(Configuration conf, JSONArray list) throws JSONException, TwitterException {
    if (conf.isJSONStoreEnabled()) {
        DataObjectFactoryUtil.clearThreadLocalMap();
    }
    int size = list.length();
    ResponseList<Status> statuses = new ResponseListImpl<Status>(size, null);
    for (int i = 0; i < size; i++) {
        JSONObject json = list.getJSONObject(i);
        Status status = new StatusJSONImpl(json);
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(status, json);
        }
        statuses.add(status);
    }
    if (conf.isJSONStoreEnabled()) {
        DataObjectFactoryUtil.registerJSONObject(statuses, list);
    }
    return statuses;
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:20,代码来源:StatusJSONImpl.java

示例7: createUserListList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<UserList> createUserListList(HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        JSONArray list = res.asJSONArray();
        int size = list.length();
        ResponseList<UserList> users = new ResponseListImpl<UserList>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject userListJson = list.getJSONObject(i);
            UserList userList = new UserListJSONImpl(userListJson);
            users.add(userList);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(userList, userListJson);
            }
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(users, list);
        }
        return users;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:UserListJSONImpl.java

示例8: createLocationList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<Location> createLocationList(JSONArray list, boolean storeJSON) throws TwitterException {
    try {
        int size = list.length();
        ResponseList<Location> locations =
                new ResponseListImpl<Location>(size, null);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            Location location = new LocationJSONImpl(json);
            locations.add(location);
            if (storeJSON) {
                DataObjectFactoryUtil.registerJSONObject(location, json);
            }
        }
        if (storeJSON) {
            DataObjectFactoryUtil.registerJSONObject(locations, list);
        }
        return locations;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:24,代码来源:LocationJSONImpl.java

示例9: createSavedSearchList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<SavedSearch> createSavedSearchList(HttpResponse res, Configuration conf) throws TwitterException {
    if (conf.isJSONStoreEnabled()) {
        DataObjectFactoryUtil.clearThreadLocalMap();
    }
    JSONArray json = res.asJSONArray();
    ResponseList<SavedSearch> savedSearches;
    try {
        savedSearches = new ResponseListImpl<SavedSearch>(json.length(), res);
        for (int i = 0; i < json.length(); i++) {
            JSONObject savedSearchesJSON = json.getJSONObject(i);
            SavedSearch savedSearch = new SavedSearchJSONImpl(savedSearchesJSON);
            savedSearches.add(savedSearch);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(savedSearch, savedSearchesJSON);
            }
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(savedSearches, json);
        }
        return savedSearches;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + res.asString(), jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:25,代码来源:SavedSearchJSONImpl.java

示例10: createFriendshipList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<Friendship> createFriendshipList(HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        JSONArray list = res.asJSONArray();
        int size = list.length();
        ResponseList<Friendship> friendshipList = new ResponseListImpl<Friendship>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            Friendship friendship = new FriendshipJSONImpl(json);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(friendship, json);
            }
            friendshipList.add(friendship);
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(friendshipList, list);
        }
        return friendshipList;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:FriendshipJSONImpl.java

示例11: getURLEntitiesFromJSON

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
/**
 * Get URL Entities from JSON Object.
 * returns URLEntity array by entities/[category]/urls/url[]
 * 
 * @param json user json object
 * @param category entities category. e.g. "description" or "url"
 * @return URLEntity array by entities/[category]/urls/url[]
 * @throws JSONException
 * @throws TwitterException
 */
private static URLEntity[] getURLEntitiesFromJSON(JSONObject json, String category) throws JSONException, TwitterException {
    if (!json.isNull("entities")) {
        JSONObject entitiesJSON = json.getJSONObject("entities");
        if (!entitiesJSON.isNull(category)) {
            JSONObject descriptionEntitiesJSON = entitiesJSON.getJSONObject(category);
            if (!descriptionEntitiesJSON.isNull("urls")) {
                JSONArray urlsArray = descriptionEntitiesJSON.getJSONArray("urls");
                int len = urlsArray.length();
                URLEntity[] urlEntities = new URLEntity[len];
                for (int i = 0; i < len; i++) {
                    urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i));
                }
                return urlEntities;
            }
        }
    }
    return null;
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:29,代码来源:UserJSONImpl.java

示例12: createUserList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<User> createUserList(JSONArray list, HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        int size = list.length();
        ResponseList<User> users =
                new ResponseListImpl<User>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            User user = new UserJSONImpl(json);
            users.add(user);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(user, json);
            }
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(users, list);
        }
        return users;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    } catch (TwitterException te) {
        throw te;
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:UserJSONImpl.java

示例13: AccountSettingsJSONImpl

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
private AccountSettingsJSONImpl(HttpResponse res, JSONObject json) throws TwitterException {
    super(res);
    try {
        JSONObject sleepTime = json.getJSONObject("sleep_time");
        SLEEP_TIME_ENABLED = getBoolean("enabled", sleepTime);
        SLEEP_START_TIME = sleepTime.getString("start_time");
        SLEEP_END_TIME = sleepTime.getString("end_time");
        if (json.isNull("trend_location")) {
            TREND_LOCATION = new Location[0];
        } else {
            JSONArray locations = json.getJSONArray("trend_location");
            TREND_LOCATION = new Location[locations.length()];
            for (int i = 0; i < locations.length(); i++) {
                TREND_LOCATION[i] = new LocationJSONImpl(locations.getJSONObject(i));
            }
        }
        GEO_ENABLED = getBoolean("geo_enabled", json);
        LANGUAGE = json.getString("language");
        ALWAYS_USE_HTTPS = getBoolean("always_use_https", json);
        DISCOVERABLE_BY_EMAIL = getBoolean("discoverable_by_email", json);
        TIMEZONE = new TimeZoneJSONImpl(json.getJSONObject("time_zone"));
        SCREEN_NAME = json.getString("screen_name");
    } catch (JSONException e) {
        throw new TwitterException(e);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:AccountSettingsJSONImpl.java

示例14: QueryResultJSONImpl

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
QueryResultJSONImpl(HttpResponse res, Configuration conf) throws TwitterException {
    super(res);
    JSONObject json = res.asJSONObject();
    try {
        JSONObject searchMetaData = json.getJSONObject("search_metadata");
        completedIn = getDouble("completed_in", searchMetaData);
        count = getInt("count", searchMetaData);
        maxId = getLong("max_id", searchMetaData);
        nextResults = searchMetaData.has("next_results") ? searchMetaData.getString("next_results") : null;
        query = getURLDecodedString("query", searchMetaData);
        refreshUrl = getUnescapedString("refresh_url", searchMetaData);
        sinceId = getLong("since_id", searchMetaData);

        JSONArray array = json.getJSONArray("statuses");
        tweets = new ArrayList<Status>(array.length());
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        for (int i = 0; i < array.length(); i++) {
            JSONObject tweet = array.getJSONObject(i);
            tweets.add(new StatusJSONImpl(tweet, conf));
        }
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:27,代码来源:QueryResultJSONImpl.java

示例15: createStatusList

import twitter4j.internal.org.json.JSONArray; //导入方法依赖的package包/类
static ResponseList<Status> createStatusList(HttpResponse res, Configuration conf) throws TwitterException {
    try {
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
        }
        JSONArray list = res.asJSONArray();
        int size = list.length();
        ResponseList<Status> statuses = new ResponseListImpl<Status>(size, res);
        for (int i = 0; i < size; i++) {
            JSONObject json = list.getJSONObject(i);
            Status status = new StatusJSONImpl(json);
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.registerJSONObject(status, json);
            }
            statuses.add(status);
        }
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.registerJSONObject(statuses, list);
        }
        return statuses;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:25,代码来源:StatusJSONImpl.java


注:本文中的twitter4j.internal.org.json.JSONArray.getJSONObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。