I get the following json response from my api in my android application, i am using Gson deserialization to parse my data and populate my listview.
API Response:
{
"message":"success",
"success":"1",
"sessionKey":"a422e60213322845b85ae122de53269f",
"data":"[{\"system_id\":1,\"logo_url\":\"https:\\\/\\\/www.beta.system.com\\\/api\\\/icons\\\/3244ffjg.jpg\",\"organization_name\":\"Test Organasation\"}]"
}
My Class:
public class SystemResponse {
@Expose
@SerializedName("message")
private String message;
@Expose
@SerializedName("success")
private String statusCode;
@Expose
@SerializedName("sessionKey")
private String sessionKey;
@Expose
@SerializedName("data")
private List<System> data;
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getSessionKey() {
return sessionKey;
}
public void setSessionKey(String sessionKey) {
this.sessionKey = sessionKey;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<System> getSystems() {
return data;
}
public void setSystems(List<System> data) {
this.data = data;
}
public static class System{
@Expose
@SerializedName("system_id")
private Long systemId;
@Expose
@SerializedName("logo_url")
private String logoUrl;
@Expose
@SerializedName("organization_name")
private String organizationName;
public Long getSystemId() {
return systemId;
}
public void setSystemId(Long systemId) {
this.systemId = systemId;
}
public String getLogoUrl() {
return logoUrl;
}
public void setLogoUrl(String logoUrl) {
this.logoUrl = logoUrl;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
}
}
Api Request service, omitted the other code:
public Observable<SystemResponse> doServerAccountRequestApiCall(String param) {
return Rx2AndroidNetworking.get(ApiEndPoint.ENDPOINT_GET_ACCOUNTS)
.build()
.getObjectObservable(SystemResponse.class);
}
Request api call in my controller class, omitted the other code.
getCompositeDisposable().add(getDataManager() .doServerAccountRequestApiCall(params))
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<SystemResponse>() {
@Override
public void accept(@NonNull SystemResponse response)
throws Exception {
//error here
}
}, new Consumer<Throwable>() {}));
I am getting getting this error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 92 path $.data