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


Java JSONObject.getJSONObject方法代码示例

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


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

示例1: createRateLimitStatuses

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
static Map<String, RateLimitStatus> createRateLimitStatuses(JSONObject json) throws TwitterException {
    Map<String, RateLimitStatus> map = new HashMap<String, RateLimitStatus>();
    try {
        JSONObject resources = json.getJSONObject("resources");
        Iterator resourceKeys = resources.keys();
        while (resourceKeys.hasNext()) {
            JSONObject resource = resources.getJSONObject((String) resourceKeys.next());
            Iterator endpointKeys = resource.keys();
            while (endpointKeys.hasNext()) {
                String endpoint = (String) endpointKeys.next();
                JSONObject rateLimitStatusJSON = resource.getJSONObject(endpoint);
                RateLimitStatus rateLimitStatus = new RateLimitStatusJSONImpl(rateLimitStatusJSON);
                map.put(endpoint, rateLimitStatus);
            }
        }
        return Collections.unmodifiableMap(map);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:21,代码来源:RateLimitStatusJSONImpl.java

示例2: getURLEntitiesFromJSON

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的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

示例3: AccountSettingsJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的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

示例4: init

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private void init(JSONObject json) throws TwitterException {
    id = getLong("id", json);
    idStr = getRawString("id_str", json);
    name = getRawString("name", json);
    fullName = getRawString("full_name", json);
    slug = getRawString("slug", json);
    description = getRawString("description", json);
    subscriberCount = getInt("subscriber_count", json);
    memberCount = getInt("member_count", json);
    uri = getRawString("uri", json);
    mode = "public".equals(getRawString("mode", json));
    following = getBoolean("following", json);

    try {
        if (!json.isNull("user")) {
            user = new UserJSONImpl(json.getJSONObject("user"));
        }
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:22,代码来源:UserListJSONImpl.java

示例5: LocationJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
public LocationJSONImpl(JSONObject location) throws TwitterException {
    super(location);
    try {
        woeid = getInt("woeid", location);
        countryName = getUnescapedString("country", location);
        countryCode = getRawString("countryCode", location);
        if (!location.isNull("placeType")) {
            JSONObject placeJSON = location.getJSONObject("placeType");
            placeName = getUnescapedString("name", placeJSON);
            placeCode = getInt("code", placeJSON);
        } else {
            placeName = null;
            placeCode = -1;
        }
        name = getUnescapedString("name", location);
        url = getUnescapedString("url", location);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:21,代码来源:LocationJSONImpl.java

示例6: ControlStreamInfo

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
ControlStreamInfo(StreamController controller, JSONObject json) throws TwitterException {
    this.controller = controller;
    try {
        JSONObject info = json.getJSONObject("info");
        includeFollowingsActivity = getBoolean("include_followings_activity", info);
        includeUserChanges = getBoolean("include_user_changes", info);
        replies = getRawString("replies", info);
        with = getRawString("with", info);
        JSONArray usersJSON = info.getJSONArray("users");
        users = new StreamController.User[usersJSON.length()];
        for (int i = 0; i < usersJSON.length(); i++) {
            users[i] = this.controller.createUser(usersJSON.getJSONObject(i));
        }

    } catch (JSONException e) {
        throw new TwitterException(e);
    }

}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:ControlStreamInfo.java

示例7: init

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private void init(JSONObject json) throws TwitterException {
    try {
        JSONObject follow = json.getJSONObject("follow");
        JSONArray idList = follow.getJSONArray("friends");
        ids = new long[idList.length()];
        for (int i = 0; i < idList.length(); i++) {
            try {
                ids[i] = Long.parseLong(idList.getString(i));
            } catch (NumberFormatException nfe) {
                throw new TwitterException("Twitter API returned malformed response: " + json, nfe);
            }
        }
        user = new User(follow.getJSONObject("user"));
        previousCursor = z_T4JInternalParseUtil.getLong("previous_cursor", json);
        nextCursor = z_T4JInternalParseUtil.getLong("next_cursor", json);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:StreamController.java

示例8: createRateLimitStatuses

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
static Map<String,RateLimitStatus> createRateLimitStatuses(JSONObject json) throws TwitterException {
    Map<String, RateLimitStatus> map = new HashMap<String, RateLimitStatus>();
    try {
        JSONObject resources = json.getJSONObject("resources");
        Iterator resourceKeys = resources.keys();
        while (resourceKeys.hasNext()) {
            JSONObject resource = resources.getJSONObject((String) resourceKeys.next());
            Iterator endpointKeys = resource.keys();
            while (endpointKeys.hasNext()) {
                String endpoint = (String) endpointKeys.next();
                JSONObject rateLimitStatusJSON = resource.getJSONObject(endpoint);
                RateLimitStatus rateLimitStatus = new RateLimitStatusJSONImpl(rateLimitStatusJSON);
                map.put(endpoint, rateLimitStatus);
            }
        }
        return Collections.unmodifiableMap(map);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:21,代码来源:RateLimitStatusJSONImpl.java

示例9: getURLEntitiesFromJSON

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的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

示例10: AccountSettingsJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的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

示例11: QueryResultJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的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

示例12: init

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private void init(JSONObject json) throws TwitterException {
    id = getInt("id", json);
    name = getRawString("name", json);
    fullName = getRawString("full_name", json);
    slug = getRawString("slug", json);
    description = getRawString("description", json);
    subscriberCount = getInt("subscriber_count", json);
    memberCount = getInt("member_count", json);
    uri = getRawString("uri", json);
    mode = "public".equals(getRawString("mode", json));
    following = getBoolean("following", json);

    try {
        if (!json.isNull("user")) {
            user = new UserJSONImpl(json.getJSONObject("user"));
        }
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:21,代码来源:UserListJSONImpl.java

示例13: RelationshipJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
RelationshipJSONImpl(HttpResponse res, JSONObject json) throws TwitterException {
    super(res);
    try {
        JSONObject relationship = json.getJSONObject("relationship");
        JSONObject sourceJson = relationship.getJSONObject("source");
        JSONObject targetJson = relationship.getJSONObject("target");
        sourceUserId = getLong("id", sourceJson);
        targetUserId = getLong("id", targetJson);
        sourceUserScreenName = getUnescapedString("screen_name", sourceJson);
        targetUserScreenName = getUnescapedString("screen_name", targetJson);
        sourceBlockingTarget = getBoolean("blocking", sourceJson);
        sourceFollowingTarget = getBoolean("following", sourceJson);
        sourceFollowedByTarget = getBoolean("followed_by", sourceJson);
        sourceCanDm = getBoolean("can_dm", sourceJson);
        sourceNotificationsEnabled = getBoolean("notifications_enabled", sourceJson);
        wantRetweets = getBoolean("want_retweets", sourceJson);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:21,代码来源:RelationshipJSONImpl.java

示例14: LocationJSONImpl

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
LocationJSONImpl(JSONObject location) throws TwitterException {
    try {
        woeid = getInt("woeid", location);
        countryName = getUnescapedString("country", location);
        countryCode = getRawString("countryCode", location);
        if (!location.isNull("placeType")) {
            JSONObject placeJSON = location.getJSONObject("placeType");
            placeName = getUnescapedString("name", placeJSON);
            placeCode = getInt("code", placeJSON);
        } else {
            placeName = null;
            placeCode = -1;
        }
        name = getUnescapedString("name", location);
        url = getUnescapedString("url", location);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:20,代码来源:LocationJSONImpl.java

示例15: createSimilarPlaces

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
static SimilarPlaces createSimilarPlaces(HttpResponse res, Configuration conf) throws TwitterException {
    JSONObject json = null;
    try {
        json = res.asJSONObject();
        JSONObject result = json.getJSONObject("result");
        return new SimilarPlacesImpl(PlaceJSONImpl.createPlaceList(result.getJSONArray("places"), res, conf), res
                , result.getString("token"));
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + json.toString(), jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:12,代码来源:SimilarPlacesImpl.java


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