本文整理汇总了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);
}
}
示例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);
}
}