I am trying to parse json to a POJO using retrofit, but keeps getting an error. It seems to get the data and as far as I can see from the logcat i reads and parses the json correctly. But it returns succes=false and do not return a responsedata object. The error type and error message reads null. I have no idea of what is wrong and would appreciate any suggestions to solutions or how to locate the error.
Json
{
"competition_info": {
"headline": "competition",
"description": "description for competition.",
"accept_button": "OK",
"open_terms_button": "Open info"
},
"terms": {
"html": "a website in html"
}
}
MyPojo
public class AnnComResponses{
@SerializedName("competition_info")
public CompetitionInfo competitionInfo;
@SerializedName("terms")
public Terms terms;
public class Terms{
@SerializedName("html")
public String html;
public String getTerms() {
return html;
}
}
public class CompetitionInfo{
@SerializedName("headline")
public String headline;
@SerializedName("description")
public String description;
@SerializedName("accept_button")
public String acceptButton;
@SerializedName("open_terms_button")
public String openTermsButton;
public String getHeadline() {
return headline;
}
public String getDescription() {
return description;
}
public String getAcceptButton() {
return acceptButton;
}
public String getOpenTermsButton() {
return openTermsButton;
}
}
}
Try using GSON converter with retrofit as below :
RestAdapter restAdapter = new RestAdapter.Builder()
.setLogLevel(RestAdapter.LogLevel.FULL)
.setConverter(new GsonConverter(new GsonBuilder()).create()))
.setEndpoint("your api end point goes here")
.build();
YourAPI api = restAdapter.create(YourAPI.class);