Я думаю, что вы можете использовать модифицированную библиотеку, добавить зависимости в приложение gradle.
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:retrofit:2.5'
Создание класса пользователя для получения ответа.
public class User {
@SerializedName("login")
@Expose
private String login;
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("node_id")
@Expose
private String nodeId;
@SerializedName("avatar_url")
@Expose
private String avatarUrl;
@SerializedName("gravatar_id")
@Expose
private String gravatarId;
@SerializedName("url")
@Expose
private String url;
@SerializedName("html_url")
@Expose
private String htmlUrl;
@SerializedName("followers_url")
@Expose
private String followersUrl;
@SerializedName("following_url")
@Expose
private String followingUrl;
@SerializedName("gists_url")
@Expose
private String gistsUrl;
@SerializedName("starred_url")
@Expose
private String starredUrl;
@SerializedName("subscriptions_url")
@Expose
private String subscriptionsUrl;
@SerializedName("organizations_url")
@Expose
private String organizationsUrl;
@SerializedName("repos_url")
@Expose
private String reposUrl;
@SerializedName("events_url")
@Expose
private String eventsUrl;
@SerializedName("received_events_url")
@Expose
private String receivedEventsUrl;
@SerializedName("type")
@Expose
private String type;
@SerializedName("site_admin")
@Expose
private Boolean siteAdmin;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getAvatarUrl() {
return avatarUrl;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public String getGravatarId() {
return gravatarId;
}
public void setGravatarId(String gravatarId) {
this.gravatarId = gravatarId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHtmlUrl() {
return htmlUrl;
}
public void setHtmlUrl(String htmlUrl) {
this.htmlUrl = htmlUrl;
}
public String getFollowersUrl() {
return followersUrl;
}
public void setFollowersUrl(String followersUrl) {
this.followersUrl = followersUrl;
}
public String getFollowingUrl() {
return followingUrl;
}
public void setFollowingUrl(String followingUrl) {
this.followingUrl = followingUrl;
}
public String getGistsUrl() {
return gistsUrl;
}
public void setGistsUrl(String gistsUrl) {
this.gistsUrl = gistsUrl;
}
public String getStarredUrl() {
return starredUrl;
}
public void setStarredUrl(String starredUrl) {
this.starredUrl = starredUrl;
}
public String getSubscriptionsUrl() {
return subscriptionsUrl;
}
public void setSubscriptionsUrl(String subscriptionsUrl) {
this.subscriptionsUrl = subscriptionsUrl;
}
public String getOrganizationsUrl() {
return organizationsUrl;
}
public void setOrganizationsUrl(String organizationsUrl) {
this.organizationsUrl = organizationsUrl;
}
public String getReposUrl() {
return reposUrl;
}
public void setReposUrl(String reposUrl) {
this.reposUrl = reposUrl;
}
public String getEventsUrl() {
return eventsUrl;
}
public void setEventsUrl(String eventsUrl) {
this.eventsUrl = eventsUrl;
}
public String getReceivedEventsUrl() {
return receivedEventsUrl;
}
public void setReceivedEventsUrl(String receivedEventsUrl) {
this.receivedEventsUrl = receivedEventsUrl;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getSiteAdmin() {
return siteAdmin;
}
public void setSiteAdmin(Boolean siteAdmin) {
this.siteAdmin = siteAdmin;
}
@Override
public String toString() {
return "User{" +
"login='" + login + '\'' +
", id=" + id +
", nodeId='" + nodeId + '\'' +
", avatarUrl='" + avatarUrl + '\'' +
", gravatarId='" + gravatarId + '\'' +
", url='" + url + '\'' +
", htmlUrl='" + htmlUrl + '\'' +
", followersUrl='" + followersUrl + '\'' +
", followingUrl='" + followingUrl + '\'' +
", gistsUrl='" + gistsUrl + '\'' +
", starredUrl='" + starredUrl + '\'' +
", subscriptionsUrl='" + subscriptionsUrl + '\'' +
", organizationsUrl='" + organizationsUrl + '\'' +
", reposUrl='" + reposUrl + '\'' +
", eventsUrl='" + eventsUrl + '\'' +
", receivedEventsUrl='" + receivedEventsUrl + '\'' +
", type='" + type + '\'' +
", siteAdmin=" + siteAdmin +
'}';
}
}
Создание интерфейса API для URL-адреса конечной точки.
public interface APIInterface {
@GET("/users")
Call<List<User>> getGitHubUser();
}
Создание клиента API Retrofit.
public class APIClient {
/**
* Get Retrofit Instance
*/
private static Retrofit getRetrofitInstance() {
Gson gson = new GsonBuilder()
.setLenient()
.create();
return new Retrofit.Builder()
.baseUrl("https://api.github.com")
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
public static APIInterface getApiInterface() {
return getRetrofitInstance().create(APIInterface.class);
}
}
Затем вызовите метод ниже, чтобы получить ваши данные анализа.
public void getUserList() {
APIInterface apiInterface=APIClient.getApiInterface();
Call<List<User>> call= apiInterface.getGitHubUser();
call.enqueue(new Callback<List<User>>() {
@Override
public void onResponse(Call<List<User>> call, Response<List<User>> response) {
List<User> userList= response.body();
System.out.println(userList);
}
@Override
public void onFailure(Call<List<User>> call, Throwable t) {
}
});
}