没有型号类别的改装2 [英] Retrofit 2 without Model Class
问题描述
我想问一下Retrofit 2.0
i want to ask about Retrofit 2.0
一直以来,我只知道使用GSON Converter进行翻新并获得对象.
all this time, i knew Retrofit only with GSON Converter and get the object.
但是我不知道如何用这样的API获取数据 https://hacker-news.firebaseio.com/v0/topstories.json?print = pretty
But i dont know how to get the data with API like this https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty
我正在尝试显示所有热门新闻并在我首先加载所有热门新闻之后获取对象.
i'm trying to display all top stories and get the object after i load all the top stories first.
我只知道这种老式的学校风格: http://pastebin.com/JMpwjH8H
i only know with old school style like this: http://pastebin.com/JMpwjH8H
推荐答案
对于您的示例,我很确定您可以将响应类型设置为如下所示的Integer列表:
I'm pretty sure for your example you can just set the response type as a list of Integers like this:
public interface ApiInterface {
@GET("topstories.json?print=pretty")
Call<List<Integer>> getTopStories();
}
从本质上讲,仅使用整数数组,使用POJO太复杂了.
Using a POJO would be too complex for what is essentially, just an array of Integers.
这篇关于没有型号类别的改装2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!