我通过将对象数组作为
@FieldMap
. 她就是解决这个问题的方法,
创建对象数组,
Order.Orderitems orderitems;
Map<String, String> parms = new HashMap<String, String>();
for (int i = 0; i < orderItems.size(); i++) {
orderitems = orderItems.get(i);
parms.put("ItemsList[" + i + "][id]", String.valueOf(orderitems.getId()));
parms.put("ItemsList[" + i + "][Amount]", String.valueOf(orderitems.getAmount()));
parms.put("ItemsList[" + i + "][Notes]", "");
parms.put("ItemsList[" + i + "][serviceId]", String.valueOf(orderitems.getServiceId()));
parms.put("ItemsList[" + i + "][TypeId]", String.valueOf(orderitems.getServiceTypeId()));
}
也使得API调用像,
@FormUrlEncoded
@POST("api/shidhin/UpdateOrder")
Call<CommonResponse> updateOrderItems(@Header("Authorization") String token, @Field("OrderId") int orderid, @FieldMap Map<String, String> parms);