public static UniversityInfo parse(JSONObject object) { if (object == null) { return null; } UniversityInfo universityInfo = new UniversityInfo(); universityInfo.name = object.optString(KEY_NAME); universityInfo.year = object.optLong(KEY_YEAR); universityInfo.department = object.optString(KEY_DEPARTMENT); return universityInfo; }
@Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(KEY_UID).append(" = ").append(uid).append("\r\n"); sb.append(KEY_NAME).append(" = ").append(name).append("\r\n"); sb.append(KEY_SEX).append(" = ").append(sex).append("\r\n"); sb.append(KEY_STAR).append(" = ").append(star).append("\r\n"); sb.append(KEY_ZIDOU).append(" = ").append(zidou).append("\r\n"); sb.append(KEY_VIP).append(" = ").append(vip).append("\r\n"); sb.append(KEY_BIRTHDAY).append(" = ").append(birthday).append("\r\n"); sb.append(KEY_EMAIL_HASH).append(" = ").append(emailHash).append("\r\n"); sb.append(KEY_TINYURL).append(" = ").append(tinyurl).append("\r\n"); sb.append(KEY_HEADURL).append(" = ").append(headurl).append("\r\n"); sb.append(KEY_MAINURL).append(" = ").append(mainurl).append("\r\n"); if (homeTownLocation != null) { sb.append(KEY_HOMETOWN_LOCATION).append(" = ").append("\r\n"); for (HomeTownLocation h : homeTownLocation) { sb.append(h.toString()).append("\r\n"); } } if (workInfo != null) { sb.append(KEY_WORK_INFO).append(" = ").append("\r\n"); for (WorkInfo w : workInfo) { sb.append(w.toString()).append("\r\n"); } } if (universityInfo != null) { sb.append(KEY_UNIVERSITY_INFO).append(" = ").append("\r\n"); for (UniversityInfo u : universityInfo) { sb.append(u.toString()).append("\r\n"); } } if (hsInfo != null) { sb.append(KEY_HS_INFO).append(" = ").append("\r\n"); for (HSInfo h : hsInfo) { sb.append(h.toString()).append("\r\n"); } } return sb.toString(); }
public UserInfo parse(JSONObject object) throws RenrenException { if (object == null) { return null; } uid = object.optLong(KEY_UID); name = object.optString(KEY_NAME); sex = object.optInt(KEY_SEX); star = object.optInt(KEY_STAR); zidou = object.optInt(KEY_ZIDOU); vip = object.optInt(KEY_VIP); birthday = object.optString(KEY_BIRTHDAY); emailHash = object.optString(KEY_EMAIL_HASH); tinyurl = object.optString(KEY_TINYURL); headurl = object.optString(KEY_HEADURL); mainurl = object.optString(KEY_MAINURL); homeTownLocation = HomeTownLocation.parse(object.optJSONArray(KEY_HOMETOWN_LOCATION)); workInfo = WorkInfo.parse(object.optJSONArray(KEY_WORK_INFO)); universityInfo = UniversityInfo.parse(object.optJSONArray(KEY_UNIVERSITY_INFO)); hsInfo = HSInfo.parse(object.optJSONArray(KEY_HS_INFO)); return this; }