@Override public String getJson(BaseMessage message) { try { JSONObject json = new JSONObject(); json.put("type", message.getType()); json.put("f_uid", ((GiftExMessage) message).getF_uid()); json.put("t_uid", ((GiftExMessage) message).getT_uid()); json.put("gid", ((GiftExMessage) message).getGid()); json.put("cost", ((GiftExMessage) message).getCost()); json.put("gift_res", ((GiftExMessage) message).getGift_res()); json.put("gift_record_id", ((GiftExMessage) message).getGift_record_id()); json.put("gift_name", ((GiftExMessage) message).getGift_name()); json.put("gift_info", ((GiftExMessage) message).getGift_info()); json.put("gift_img", ((GiftExMessage) message).getGift_img()); json.put("f_nickname", ((GiftExMessage) message).getF_nickname()); json.put("t_nickname", ((GiftExMessage) message).getT_nickname()); json.put("tm", getTimeStr()); return json.toString(); } catch (JSONException e) { MMLog.printThrowable(e); } return null; }
@Override public BaseMessage parseJson(String jsonStr) { super.parseJson(jsonStr); try { JSONObject object = new JSONObject(jsonStr); this.setType(object.optString("type")); this.setF_uid(object.optLong("f_uid")); this.setT_uid(object.optLong("t_uid")); this.setGid(object.optLong("gid")); this.setGift_record_id(object.optLong("gift_record_id")); this.setGift_name(object.optString("gift_name")); this.setGift_info(object.optString("gift_info")); this.setGift_img(object.optString("gift_img")); this.setGift_res(object.optString("gift_res")); this.setF_nickname(object.optString("f_nickname")); this.setT_nickname(object.optString("t_nickname")); this.setTime(setStrTime(object.optString("tm"))); return this; } catch (JSONException e) { e.printStackTrace(); } return null; }
public void fill(Map paraMap) { super.fill(paraMap); this.setEvent((String) paraMap.get("Event")); }