public void parsePointAPIMessagePost(PointMessage msg, JSONObject p) throws JSONException, ParseException { PointUser pu = new PointUser(); msg.User = pu; JSONObject author = p.getJSONObject("author"); pu.UName = author.getString("login"); pu.FullName = author.getString("name"); pu.UID = author.getInt("id"); if (author.has("avatar") && author.get("avatar") != JSONObject.NULL) pu.avatarUrl = author.getString("avatar"); msg.Text = p.getString("text"); String createdStr = p.getString("created"); msg.Timestamp = parsePointAPIDate(createdStr); msg.tags = new Vector<String>(); if (p.has("tags")) { JSONArray tagso = p.getJSONArray("tags"); for (int i = 0; i < tagso.length(); i++) { msg.tags.add(tagso.getString(i)); } } if (p.has("files")) { JSONArray fileso = p.getJSONArray("files"); for (int i = 0; i < fileso.length(); i++) { msg.Text += "\n@\n" + fileso.getString(i); } } msg.setMID(new PointMessageID(pu.UName, p.getString("id"), 0)); msg.replies = p.getInt("comments_count"); msg.microBlogCode = PointMessageID.CODE; }
private void parsePointAPIMessage(JSONObject post, PointMessage msg) throws JSONException, ParseException { JSONObject p = post.getJSONObject("post"); parsePointAPIMessagePost(msg, p); PointMessageID mid = (PointMessageID) msg.getMID(); mid.uid = post.getInt("uid"); msg.source = post.toString(); msg.subscribed = post.getBoolean("subscribed"); }
private void parsePointAPIComment(JSONObject comm, PointMessage msg, PointMessage parent) throws JSONException, ParseException { PointUser pu = new PointUser(); msg.User = pu; JSONObject author = comm.getJSONObject("author"); pu.UName = author.getString("login"); pu.FullName = author.getString("name"); pu.UID = author.getInt("id"); if (author.has("avatar") && author.get("avatar") != JSONObject.NULL) { pu.avatarUrl = author.getString("avatar"); } msg.Text = comm.getString("text"); msg.is_rec = comm.getBoolean("is_rec"); msg.Timestamp = parsePointAPIDate(comm.getString("created")); msg.setMID(parent.getMID()); msg.setRID(comm.getInt("id")); Object toCommentId = comm.get("to_comment_id"); if (toCommentId != JSONObject.NULL) { msg.setReplyTo(comm.getInt("to_comment_id")); } msg.microBlogCode = PointMessageID.CODE; }
public static BNWMessage initFromJSON(JSONObject json) throws JSONException { BNWMessage jmsg = new BNWMessage(); if (json.has("message")) { jmsg.setMID(new BnwMessageID(json.getString("message"))); jmsg.setRIDString(json.getString("id")); } else { jmsg.setMID(new BnwMessageID(json.getString("id"))); } jmsg.Text = json.getString("text"); Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); cal.setTimeInMillis((long) (json.getDouble("date") * 1000)); jmsg.Timestamp = cal.getTime(); jmsg.User = new JuickUser(); jmsg.User.UName = json.getString("user"); if (json.has("replyto") && json.get("replyto") != JSONObject.NULL) jmsg.setReplyToString(json.getString("replyto")); if (json.has("tags")) { JSONArray tags = json.getJSONArray("tags"); for (int n = 0; n < tags.length(); n++) { jmsg.tags.add(tags.getString(n).replace(""", "\"")); } } if (json.has("clubs")) { JSONArray clubs = json.getJSONArray("clubs"); for (int n = 0; n < clubs.length(); n++) { jmsg.clubs.add(clubs.getString(n).replace(""", "\"")); } } if (json.has("replycount")) { jmsg.replies = json.getInt("replycount"); } jmsg.microBlogCode = BnwMessageID.CODE; return jmsg; }