コード例 #1
0
 public ArrayList<JuickMessage> parseAPIPostAndReplies(String jsonStr) {
   ArrayList<JuickMessage> retval = new ArrayList<JuickMessage>();
   try {
     JSONObject jo = new JSONObject(new JSONTokener(new FastStringReader(jsonStr)));
     JSONObject post = jo.getJSONObject("post");
     PointMessage msg = new PointMessage();
     parsePointAPIMessagePost(msg, post);
     retval.add(msg);
     JSONArray comments = jo.getJSONArray("comments");
     for (int i = 0; i < comments.length(); i++) {
       JSONObject comment = comments.getJSONObject(i);
       PointMessage comm = new PointMessage();
       try {
         parsePointAPIComment(comment, comm, msg);
         retval.add(comm);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   } catch (ParseException e) {
     e.printStackTrace();
   }
   return retval;
 }
コード例 #2
0
 public ArrayList<JuickMessage> parseAPIMessageListPure(String jsonStr) {
   ArrayList<JuickMessage> retval = new ArrayList<JuickMessage>();
   try {
     JSONObject jo = new JSONObject(new JSONTokener(new FastStringReader(jsonStr)));
     JSONArray posts = jo.getJSONArray("posts");
     for (int i = 0; i < posts.length(); i++) {
       JSONObject post = posts.getJSONObject(i);
       PointMessage msg = new PointMessage();
       try {
         parsePointAPIMessage(post, msg);
         retval.add(msg);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
   return retval;
 }