예제 #1
0
 private static Trend[] jsonArrayToTrendArray(JSONArray array) throws JSONException {
   Trend[] trends = new Trend[array.length()];
   for (int i = 0; i < array.length(); i++) {
     JSONObject trend = array.getJSONObject(i);
     trends[i] = new Trend(trend);
   }
   return trends;
 }
예제 #2
0
 /**
  * Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
  *
  * @param names A JSONArray containing a list of key strings. These will be paired with the
  *     values.
  * @return A JSONObject, or null if there are no names or if this JSONArray has no values.
  * @throws JSONException If any of the names are null.
  */
 public JSONObject toJSONObject(JSONArray names) throws JSONException {
   if (names == null || names.length() == 0 || length() == 0) {
     return null;
   }
   JSONObject jo = new JSONObject();
   for (int i = 0; i < names.length(); i += 1) {
     jo.put(names.getString(i), this.opt(i));
   }
   return jo;
 }
예제 #3
0
 /* modify by hezhou add some field*/
 static List<Comment> constructComments(Response res) throws WeiboException {
   try {
     JSONArray list = res.asJSONArray();
     int size = list.length();
     List<Comment> comments = new ArrayList<Comment>(size);
     for (int i = 0; i < size; i++) {
       comments.add(new Comment(list.getJSONObject(i)));
     }
     return comments;
   } catch (JSONException jsone) {
     throw new WeiboException(jsone);
   } catch (WeiboException te) {
     throw te;
   }
 }