/** * Converts the useranswer object to a valid json object * * @return a json object with all the necessary data * @throws JSONException */ public JSONObject toJSONObject() throws JSONException { JSONObject o = new JSONObject(); o.put(KEY_ANSWER, answer); o.put(KEY_WEEK, week); o.put(KEY_NUM, num); return o; }
/** * Converts a json object to an UserAnswer object * * @param o a valid json object * @throws JSONException */ public void fromJSONObject(JSONObject o) throws JSONException { answer = o.getString(KEY_ANSWER); week = o.getInt(KEY_WEEK); num = o.getInt(KEY_NUM); }