在辅助构造函数中正确使用Retrofit注释的方法?

我有一个对象,它是作为POST请求的一部分发送的,并且我希望它具有多个构造函数。我的第一个直觉是制作看起来像这样的东西:

class DistributedItem(

@Expose
@SerializedName("cart_sequence_id")
val sequenceId: Int?,@Expose
@SerializedName("type")
val type: String?,@Expose
@SerializedName("paid")
val amountPaid: Int?

) {
constructor(
    @Expose
    @SerializedName("cart_sequence_id")
    sequenceId: Int?,@Expose
    @SerializedName("type")
    type: String?,@Expose
    @SerializedName("paid")
    amountPaid: Int?,@Expose
    @SerializedName("new_parameter")
    newParameter:String: this(sequenceId,type,amountPaid)
}

但是它告诉我辅助构造函数中注释上的“注释不适用于目标'值参数'”。确保用辅助构造函数初始化的对象正确序列化以进行API调用的正确方法是什么?

jinjbnu 回答:在辅助构造函数中正确使用Retrofit注释的方法?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141295.html

大家都在问