如何添加使用改造相同/数组参数的多? [英] How to add multiple of the same/array parameter using Retrofit?

查看:108
本文介绍了如何添加使用改造相同/数组参数的多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的情况:我需要通过多个相同的命名参数到服务器(数据阵列)。

I have an instance where I need to pass multiple of the same named parameters to a server (array of data).

改变它是不是一个可能性。

Changing it is not a possibility.

http://test.com?test[]=1&test[]=2&test[]=3

我如何做到这一点与改造?我看到,你可以传递值的地图,但是这并没有帮助的按键都是相同的。

How do I accomplish this with RetroFit? I see that you can pass a map of values, but that doesn't help as the keys are all identical.

任何帮助将是巨大的......真的很希望有一个干净的方法/解决办法,否则我将需要使用另一个API lib和做一个项目重构。

Any help would be great... really hoping there's a clean way/workaround or else I'm going to need to use another api lib and do a project refactor.

推荐答案

改造为1.4.0加入到发送数组或列表作为 @Field 或能力 @Query 参数。

Retrofit as of 1.4.0 added the ability to send an array or List as a @Field or @Query parameter.

New: @Query and @EncodedQuery now accept List or arrays for multiple values.
New: @Field now accepts List or arrays for multiple values.

这篇关于如何添加使用改造相同/数组参数的多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆