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


Java JSONObject.isNull方法代码示例

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


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

示例1: init

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private void init(JSONObject json) throws TwitterException {
    try {
        JSONArray indicesArray = json.getJSONArray("indices");
        setStart(indicesArray.getInt(0));
        setEnd(indicesArray.getInt(1));

        if (!json.isNull("name")) {
            this.name = json.getString("name");
        }
        if (!json.isNull("screen_name")) {
            this.screenName = json.getString("screen_name");
        }
        id = z_T4JInternalParseUtil.getLong("id", json);
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:18,代码来源:UserMentionEntityJSONImpl.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 {
    try {
        JSONArray indicesArray = json.getJSONArray("indices");
        setStart(indicesArray.getInt(0));
        setEnd(indicesArray.getInt(1));

        this.url = json.getString("url");
        if (!json.isNull("expanded_url")) {
            // sets expandedURL to url if expanded_url is null
            // http://jira.twitter4j.org/browse/TFJ-704
            this.expandedURL = json.getString("expanded_url");
        }else{
            this.expandedURL = url;
        }

        if (!json.isNull("display_url")) {
            // sets displayURL to url if expanded_url is null
            // http://jira.twitter4j.org/browse/TFJ-704
            this.displayURL = json.getString("display_url");
        }else{
            this.displayURL = url;
        }
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:27,代码来源:URLEntityJSONImpl.java

示例5: 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

示例6: extractLocation

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private static Location extractLocation(JSONObject json, boolean storeJSON) throws TwitterException {
    if (json.isNull("locations")) {
        return null;
    }
    ResponseList<Location> locations;
    try {
        locations = LocationJSONImpl.createLocationList(json.getJSONArray("locations"), storeJSON);
    } catch (JSONException e) {
        throw new AssertionError("locations can't be null");
    }
    Location location;
    if (0 != locations.size()) {
        location = locations.get(0);
    } else {
        location = null;
    }
    return location;
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:19,代码来源:TrendsJSONImpl.java

示例7: init

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
private void init(JSONObject json) throws TwitterException {
    try {
        mediaId = getLong("media_id", json);
        mediaIdString = getRawString("media_id", json);
        size = getLong("size", json);
        if (!json.isNull("image")) {
            image = new TwitterImageJSONImpl(json);
        }
        if (!json.isNull("expires_after_secs")) {
            expiresAfterSecs = getLong("expires_after_secs", json);
        }
        if (!json.isNull("processing_info")) {
            JSONObject processingInfo = new JSONObject(getRawString("processing_info", json));
            if (!processingInfo.isNull("state")) {
                state = getRawString("state", processingInfo);
            }
        }
    } catch (Exception jsone) {
        throw new TwitterException(jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:22,代码来源:TwitterUploadMediaResponseImpl.java

示例8: 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

示例9: postUpload

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected String postUpload() throws TwitterException {
    int statusCode = httpResponse.getStatusCode();
    if (statusCode != 200)
        throw new TwitterException("ImgLy image upload returned invalid status code", httpResponse);

    String response = httpResponse.asString();

    try {
        JSONObject json = new JSONObject(response);
        if (!json.isNull("url"))
            return json.getString("url");
    } catch (JSONException e) {
        throw new TwitterException("Invalid ImgLy response: " + response, e);
    }

    throw new TwitterException("Unknown ImgLy response", httpResponse);
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:19,代码来源:ImgLyUpload.java

示例10: createGeoLocation

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
/**
 * returns a GeoLocation instance if a "geo" element is found.
 *
 * @param json JSONObject to be parsed
 * @return GeoLocation instance
 * @throws TwitterException when coordinates is not included in geo element (should be an API side issue)
 */
/*package*/
static GeoLocation createGeoLocation(JSONObject json) throws TwitterException {
    try {
        if (!json.isNull("coordinates")) {
            String coordinates = json.getJSONObject("coordinates")
                    .getString("coordinates");
            coordinates = coordinates.substring(1, coordinates.length() - 1);
            String[] point = z_T4JInternalStringUtil.split(coordinates, ",");
            return new GeoLocation(Double.parseDouble(point[1]),
                    Double.parseDouble(point[0]));
        }
    } catch (JSONException jsone) {
        throw new TwitterException(jsone);
    }
    return null;
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:24,代码来源:z_T4JInternalJSONImplFactory.java

示例11: 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

示例12: 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

示例13: 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

示例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: postUpload

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected String postUpload() throws TwitterException {
    int statusCode = httpResponse.getStatusCode();
    if (statusCode != 200)
        throw new TwitterException("Posterous image upload returned invalid status code", httpResponse);

    String response = httpResponse.asString();

    try {
        JSONObject json = new JSONObject(response);
        if (!json.isNull("url"))
            return json.getString("url");
    } catch (JSONException e) {
        throw new TwitterException("Invalid Posterous response: " + response, e);
    }

    throw new TwitterException("Unknown Posterous response", httpResponse);
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:19,代码来源:PosterousUpload.java


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