这是我的json,我需要把这些都贴出来。
{
"name": "name",
"type": "cash",
"PaymentStatus": true
"CartItems": [
{
"ProductId": 1,
"ProductName": "sample string 2",
"Quantity": 3,
"UnitPrice": 4.1,
"Price": 5.1
},{
"ProductId": 1,
"ProductName": "sample string 2",
"Quantity": 3,
"UnitPrice": 4.1,
"Price": 5.1
}
]
}这是我的改装界面ApiService
@Multipart
@POST("Addtocart")
Call<AddtoCartRes> createOrder(@Body Order order,
@HeaderMap HashMap<String,String> headerMap,
@Path("name") String ShopUserName,
@Path("type") String ShopName,
@Path("PaymentStatus") String SalesLogin
);这是我的订单类@SerializedName("CartItems")列表orderDetailList;
public List<Cart> getOrderDetailList() {
return orderDetailList;
}
public void setOrderDetailList(List<Cart> orderDetailList) {
this.orderDetailList = orderDetailList;
}发布于 2019-05-24 20:54:06
您的请求模型类应该如下所示
public class CartItem {
private int ProductId;
private String ProductName;
private int Quantity;
private int UnitPrice;
private int Price;
public void setProductId(int productId) {
ProductId = productId;
}
public void setProductName(String productName) {
ProductName = productName;
}
public void setQuantity(int quantity) {
Quantity = quantity;
}
public void setUnitPrice(int unitPrice) {
UnitPrice = unitPrice;
}
public void setPrice(int price) {
Price = price;
}
}这是请求模型类
public class MyRequestModel {
private String name;
private String type;
private int PaymentStatus;
private List<CartItem > CartItems;
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public void setPaymentStatus(int paymentStatus) {
PaymentStatus = paymentStatus;
}
public void setCartItems(List<CartItem> cartItems) {
CartItems = cartItems;
}
}你的Api看起来像这样
@POST("Addtocart")
Call<AddtoCartRes> createOrder(@HeaderMap HashMap<String,String> headerMap,
@Body MyRequestModel order);https://stackoverflow.com/questions/53542530
复制相似问题