diff options
Diffstat (limited to 'src/com/juick/json/User.java')
-rw-r--r-- | src/com/juick/json/User.java | 25 |
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; + } } |