Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.json.simple.JSONObject;
- public class Account {
- private int id;
- private String username;
- private String name;
- private String email;
- private String password;
- public Account (int id, String username, String name, String email, String password) {
- this.id = id;
- this.username = username;
- this.name = name;
- this.email = email;
- this.password = password;
- }
- public int getId() {
- return id;
- }
- public String getUsername() {
- return username;
- }
- public String getName() {
- return name;
- }
- public String getEmail() {
- return email;
- }
- public String getPassword() {
- return password;
- }
- public static Account fromJSON (JSONObject account) {
- return new Account (
- ((Long) account.get("id")).intValue(), // ((Long) account.get("id")).intValue(),
- (String) account.get("username"),
- (String) account.get("name"),
- (String) account.get("email"),
- (String) account.get("password")
- );
- }
- public JSONObject toJSON () {
- JSONObject userJsonObject = new JSONObject();
- userJsonObject.put("id", id);
- userJsonObject.put("username", username);
- userJsonObject.put("name", name);
- userJsonObject.put("email", email);
- userJsonObject.put("password", password);
- return userJsonObject;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement