Java 如何为get方法编写数组的改型查询?
我在处理Java 如何为get方法编写数组的改型查询?,java,android,kotlin,retrofit2,Java,Android,Kotlin,Retrofit2,我在处理 @GET("match-details/5-days") fun callMatchDetails(@Query("competition_id[]", encoded = true) competitionIdList: List<String> ): Call<MatchDetailResponseModel>? @GET(“匹配详细信息/5天”) fun callMatchDetails(@Query(“compe
@GET("match-details/5-days")
fun callMatchDetails(@Query("competition_id[]", encoded = true) competitionIdList: List<String>
): Call<MatchDetailResponseModel>?
@GET(“匹配详细信息/5天”)
fun callMatchDetails(@Query(“competition_id[]”,encoded=true)CompetitionId列表:列表
):打电话?
如下所示的url:
如何使其看起来像数组括号中的值,如下所示:
任何答案或建议均受欢迎。您可以通过三个步骤完成: 1-使用QueryMap代替查询,如下所示:
@GET("match-details/5-days")
fun callMatchDetails(
@QueryMap(encoded = true) map: Map<String, Int>
): Call<MatchDetailResponseModel>?
非常感谢,这是工作的要求。坚持下去@我的荣幸!
val ids = mutableListOf(123, 134, 156)
val map = mutableMapOf<String,Int>()
ids.forEachIndexed { index, id ->
map["competition_id[$index]"] = id
}
//mutableMapOf: {competition_id[0]=123, competition_id[1]=134, competition_id[2]=156}
https://baseurl.com/match-details/5-days?competition_id[0]=123&competition_id[1]=134&competition_id[2]=156