作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
groupList1(@QueryMa-6ren">
我有一些请求具有相同的端点,但参数和返回类型不同。
我用了@QueryMap
作为参数,但我不知道如何写返回类型:
我必须写:
@GET("xxx")
Call<List<A1>> groupList1(@QueryMap Map<String, String> options);
@GET("xxx")
Call<List<A2>> groupList2(@QueryMap Map<String, String> options);
@GET("xxx")
Call<List<A3>> groupList3(@QueryMap Map<String, String> options);
....
或者有更短的解决方案?
最佳答案
你可以使用JsonElement
响应类型
@GET("xxx")
Call<JsonElement> groupList(@QueryMap Map<String, String> options);
每次调用您都会收到 JsonElement
,您可以将其转换为 JsonObject
或 JsonArray
甚至 String
。您可以根据您的内容解析/取消实现它
public void onResponse(Call<JsonElement> call, Response<JsonElement> response) {
JsonElement jsonElement = response.body();
//JsonArray array = jsonElement.getAsJsonArray();
//JsonObject Obj = jsonElement .getAsJsonObject();
}
关于android - 使用 QueryMap 改造,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37766953/
我正在尝试像这样查询 github api... https://api.github.com/search/repositories?q=created:>=2015-07-11&sort=star
我有一些请求具有相同的端点,但参数和返回类型不同。 我用了@QueryMap作为参数,但我不知道如何写返回类型: 我必须写: @GET("xxx") Call> groupList1(@QueryMa
我正在使用 Spark java 作为我的 API。我有以下网址 get("/template/:id") -> controller.getById(req, res).handle(req, re
我的 Html 是 01 - Big Love.WAV
我是一名优秀的程序员,十分优秀!