retrofit android
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
retrofit android
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
how to get json array response in retrofit
@FormUrlEncoded
@POST("api/sponsors")
Call<List<SponsorsResult>> getStatesAndDistrict(
@Field("xyz") String field1
);
Call <List<SponsorsResult>> call = service.getSponsorsValue();
call.enqueue(new Callback<List<SponsorsResult>>() {
@Override
public void onResponse(Call<List<SponsorsResult>> call, Response<List<SponsorsResult>> response) {
List<SponsorsResult> rs = response.body();
}
@Override
public void onFailure(Call<List<SponsorsResult>> call, Throwable t) {
}
});
class SponsorsResult {
@SerializedName("sponsors")
private List<SponsorsValue> sponsors;
public List<SponsorsValue> getSponsors() {
return sponsors;
}
}
class SponsorsValue{
@SerializedName("leg_id")
@Expose
private String legId;
@SerializedName("type")
@Expose
private String type;
@SerializedName("name")
@Expose
private String name;
public String getLegId() {
return legId;
}
public void setLegId(String legId) {
this.legId = legId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us