use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.
the class User method constructIds.
public static String[] constructIds(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONObject().getJSONArray("ids");
String temp = list.toString().substring(1, list.toString().length() - 1);
String[] ids = temp.split(",");
return ids;
} catch (JSONException jsone) {
throw new WeiboException(jsone.getMessage() + ":" + jsone.toString(), jsone);
}
}
use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.
the class Comment method constructWapperComments.
public static CommentWapper constructWapperComments(Response res) throws WeiboException {
//asJSONArray();
JSONObject json = res.asJSONObject();
try {
JSONArray comments = json.getJSONArray("comments");
int size = comments.length();
List<Comment> comment = new ArrayList<Comment>(size);
for (int i = 0; i < size; i++) {
comment.add(new Comment(comments.getJSONObject(i)));
}
long previousCursor = json.getLong("previous_curosr");
long nextCursor = json.getLong("next_cursor");
long totalNumber = json.getLong("total_number");
String hasvisible = json.getString("hasvisible");
return new CommentWapper(comment, previousCursor, nextCursor, totalNumber, hasvisible);
} catch (JSONException jsone) {
throw new WeiboException(jsone);
}
}
use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.
the class Emotion method constructEmotions.
public static List<Emotion> constructEmotions(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONArray();
int size = list.length();
List<Emotion> emotions = new ArrayList<Emotion>(size);
for (int i = 0; i < size; i++) {
emotions.add(new Emotion(list.getJSONObject(i)));
}
return emotions;
} catch (JSONException jsone) {
throw new WeiboException(jsone);
} catch (WeiboException te) {
throw te;
}
}
use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.
the class FavoritesTag method constructTags.
public static List<FavoritesTag> constructTags(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONArray();
int size = list.length();
List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
for (int i = 0; i < size; i++) {
tags.add(new FavoritesTag(list.getJSONObject(i)));
}
return tags;
} catch (JSONException jsone) {
throw new WeiboException(jsone);
} catch (WeiboException te) {
throw te;
}
}
use of weibo4j.org.json.JSONArray in project twitter-2-weibo by rjyo.
the class Status method constructWapperStatus.
public static StatusWapper constructWapperStatus(Response res) throws WeiboException {
//asJSONArray();
JSONObject jsonStatus = res.asJSONObject();
JSONArray statuses = null;
try {
if (!jsonStatus.isNull("statuses")) {
statuses = jsonStatus.getJSONArray("statuses");
}
if (!jsonStatus.isNull("reposts")) {
statuses = jsonStatus.getJSONArray("reposts");
}
int size = statuses.length();
List<Status> status = new ArrayList<Status>(size);
for (int i = 0; i < size; i++) {
status.add(new Status(statuses.getJSONObject(i)));
}
long previousCursor = jsonStatus.getLong("previous_curosr");
long nextCursor = jsonStatus.getLong("next_cursor");
long totalNumber = jsonStatus.getLong("total_number");
String hasvisible = jsonStatus.getString("hasvisible");
return new StatusWapper(status, previousCursor, nextCursor, totalNumber, hasvisible);
} catch (JSONException jsone) {
throw new WeiboException(jsone);
}
}
Aggregations