android - Should developer create a different model of Login Request & Response -


i using gson library in demo android project. want know should create different model login request & login response in json.

for request created below

public class login {      private string username;     private string password;      public string getusername() {         return username;     }      public void setusername(string username) {         this.username = username;     }      public string getpassword() {         return password;     }      public void setpassword(string password) {         this.password = password;     } } 

creating json login request.

// creating json using gson library login mlogin = new login(); mlogin.setusername(username); mlogin.setpassword(password);  gson gson = new gsonbuilder().create(); string loginjson = gson.tojson(mlogin); 

so here above created model login request & should create new model of login response again in json or not doing following correct approach.

gson helps serialize , deserialize json objects/strings make our coding life easier. if want can write own json parser or use json parsers such jackson. can work on pure string value of jsons because json formatted string xml representation.

pojos json values make coding, reading code, maintenance easier. prefer having pojo classes both input , output json values.(that choice)

i created model login request & should create new model of login response again in json or not doing following correct approach.

the answer of question is; it's you. if need pojo class should write it. if don't may prefer write or handle json without pojos. (by using gson can get/create json arrays, objects, values.)

you can see previous answer question clear.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -