samedi 31 janvier 2015

Should I define one class for each REST JSON Request and Response?

In my android app, I need to post JSON data to several REST APIs and get JSON data back for parsing. I want to use GSON to serialize/deserialize the data.


Each REST API has different input/output fields, should I define a separate class to hold data for each API request and response like this?



public class API1RequestData{
public String field1;
public String field2;
}


I am asking this, because if I am using python to construct the JSON request, I don't need to define classes, a dictionary will do.





Aucun commentaire:

Enregistrer un commentaire