问题
i want to ask about Retrofit 2.0
all this time, i knew Retrofit only with GSON Converter and get the object.
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.
i only know with old school style like this: http://pastebin.com/JMpwjH8H
回答1:
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();
}
Using a POJO would be too complex for what is essentially, just an array of Integers.
回答2:
First of all, you should know whether it is POST web service or GET web service. what parameters you will be giving to get the desired response and how would you store the response in POJO. This tutorial will help you with all basic thing that you require for integrating web services
来源:https://stackoverflow.com/questions/37119905/retrofit-2-without-model-class