1
作为@Query
注释上面the Retrofit documentation指出:更改列表/阵列的URL格式为[改造2]
传递一个列表或阵列将导致在每个 非空条目的查询参数。
截至目前我的电话看起来是这样的:
@GET("questions")
Call<List<QuestionHolder>> getQuestionsExcludingTheSpecified(
@Query("exclude_ids") long[] excludedQuestionIds
);
这工作,但结果相当长的URL相当快。
E.g.对于excludedQuestionIds = new long[]{1L, 4L, 16L, 64L}
请求URL已经是/questions?exclude_ids=1&exclude_ids=4&exclude_ids=16&exclude_ids=64
。
有没有一种简单的方法来交换导致格式化为exclude_ids=[1,4,16,64]
或类似的东西数组这种行为?
什么来到我的脑海里又是到:
- 使用JsonArray作为参数,但后来我需要打出电话
- 截获每个请求之前,每个阵列/列表转换和压缩重复键
- 覆盖内置
@Query
装饰
任何想法?