2014-12-04 45 views
0

我试图动态改变后param的名字。是否可以使用Robospice + Retrofit动态设置一个名称参数?

@FormUrlEncoded 
    @POST("/payment/send_rc") 
    Abuse setTop(@Field("MrchLogin") String login, 
       @Field("OutSum") int sum, 
       @Field("InvId") int invId, 
       @Field("Desc") String paymentDescription, 
       @Field("shp_payment_no") int adtId, 
       @Field("shp_type") int number, 
       @Field("shp_user") int userID, 
       @Field("shp_month[]") int monthPeriod); 

这是我的方法,我使用,我正在尝试设置与动态域名monthPeriod场。 因此,它可以是shp_month[n],其中n是我的自定义整数参数名称。那么是否可以动态更改帖子字段的名称?

+0

不知道你是否可以改变API,但为什么不使用Json数组呢? – 2014-12-04 17:08:21

+0

你能解释一下你的答案或者给我一个链接吗? – StupidFox 2014-12-04 17:10:42

+0

在Retrofit中,通常JSON数组表示为“arrayName”:[any-other-entities-inside-square-bracets]',这相当于使用List作为字段类型(在您的情况下为'List monthPeriods') – 2014-12-04 17:14:55

回答

3

由于杰克沃顿

You can use a "@FieldMap Map<String, String>" for that. 

貌似Robospice改造模块是过时的。

相关问题