aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/json/User.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2012-01-22 23:01:24 +0700
committerGravatar Ugnich Anton2012-01-22 23:01:24 +0700
commitcbcc5a5e4c1edd4689c756a2548a5087201ee74e (patch)
treea6b0d603af873ba3de7830121c3aedaa99f3f6c1 /src/com/juick/json/User.java
parentbd7cfe95f4d15719f31e17d9aee6830066644948 (diff)
toJSON()
Diffstat (limited to 'src/com/juick/json/User.java')
-rw-r--r--src/com/juick/json/User.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java
index b4e0e7e8..43ee4803 100644
--- a/src/com/juick/json/User.java
+++ b/src/com/juick/json/User.java
@@ -24,10 +24,10 @@ import org.json.JSONObject;
*
* @author Ugnich Anton
*/
-public class User extends com.juick.User {
+public class User {
- public static User parseJSON(JSONObject json) throws JSONException {
- User juser = new User();
+ public static com.juick.User parseJSON(JSONObject json) throws JSONException {
+ com.juick.User juser = new com.juick.User();
juser.UID = json.getInt("uid");
juser.UName = json.getString("uname");
if (json.has("fullname")) {
@@ -35,4 +35,23 @@ public class User extends com.juick.User {
}
return juser;
}
+
+ public static JSONObject toJSON(com.juick.User user) {
+ JSONObject json = new JSONObject();
+
+ try {
+ if (user.UID > 0) {
+ json.put("uid", user.UID);
+ }
+ if (user.UName != null) {
+ json.put("uname", user.UName);
+ }
+ if (user.FullName != null) {
+ json.put("fullname", user.FullName);
+ }
+ } catch (JSONException e) {
+ }
+
+ return json;
+ }
}