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


Java JSONObject.length方法代码示例

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


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

示例1: createTrendsList

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
static ResponseList<Trends> createTrendsList(HttpResponse res, boolean storeJSON) throws TwitterException {
    JSONObject json = res.asJSONObject();
    ResponseList<Trends> trends;
    try {
        Date asOf = z_T4JInternalParseUtil.parseTrendsDate(json.getString("as_of"));
        JSONObject trendsJson = json.getJSONObject("trends");
        Location location = extractLocation(json, storeJSON);
        trends = new ResponseListImpl<Trends>(trendsJson.length(), res);
        Iterator ite = trendsJson.keys();
        while (ite.hasNext()) {
            String key = (String) ite.next();
            JSONArray array = trendsJson.getJSONArray(key);
            Trend[] trendsArray = jsonArrayToTrendArray(array, storeJSON);
            if (key.length() == 19) {
                // current trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key, "yyyy-MM-dd HH:mm:ss"), trendsArray));
            } else if (key.length() == 16) {
                // daily trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key, "yyyy-MM-dd HH:mm"), trendsArray));
            } else if (key.length() == 10) {
                // weekly trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key, "yyyy-MM-dd"), trendsArray));
            }
        }
        Collections.sort(trends);
        return trends;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + res.asString(), jsone);
    }
}
 
开发者ID:sprinklr-inc,项目名称:twitter4j-ads,代码行数:31,代码来源:TrendsJSONImpl.java

示例2: createTrendsList

import twitter4j.internal.org.json.JSONObject; //导入方法依赖的package包/类
static ResponseList<Trends> createTrendsList(HttpResponse res, boolean storeJSON) throws
        TwitterException {
    JSONObject json = res.asJSONObject();
    ResponseList<Trends> trends;
    try {
        Date asOf = z_T4JInternalParseUtil.parseTrendsDate(json.getString("as_of"));
        JSONObject trendsJson = json.getJSONObject("trends");
        Location location = extractLocation(json, storeJSON);
        trends = new ResponseListImpl<Trends>(trendsJson.length(), res);
        Iterator ite = trendsJson.keys();
        while (ite.hasNext()) {
            String key = (String) ite.next();
            JSONArray array = trendsJson.getJSONArray(key);
            Trend[] trendsArray = jsonArrayToTrendArray(array, storeJSON);
            if (key.length() == 19) {
                // current trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key
                        , "yyyy-MM-dd HH:mm:ss"), trendsArray));
            } else if (key.length() == 16) {
                // daily trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key
                        , "yyyy-MM-dd HH:mm"), trendsArray));
            } else if (key.length() == 10) {
                // weekly trends
                trends.add(new TrendsJSONImpl(asOf, location, getDate(key
                        , "yyyy-MM-dd"), trendsArray));
            }
        }
        Collections.sort(trends);
        return trends;
    } catch (JSONException jsone) {
        throw new TwitterException(jsone.getMessage() + ":" + res.asString(), jsone);
    }
}
 
开发者ID:SamKnows,项目名称:skandroid-core,代码行数:35,代码来源:TrendsJSONImpl.java


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