gpt4 book ai didi

java - 有没有办法实现以下 JSON pojo 类以及如何将数据传递到列表?

转载 作者:行者123 更新时间:2023-12-01 21:13:11 24 4
gpt4 key购买 nike

JSON file

API调用

@POST("api/CustomerOrder/Post")
Call<ResponseBody> postData(@Body Example orderDetail);

模型类别

public class Example extends BaseResponse {

@SerializedName("CustId")
@Expose
private String custId;
@SerializedName("distId")
@Expose
private String distId;
@SerializedName("Description")
@Expose
private String description;
@SerializedName("lstCustomerOrderDetails")
@Expose
ArrayList<LstCustomerOrderDetail> orderDetails; //added get set}

调用API

mService.postData(exampleResponse)
.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
String s =response.body().string();
Toast.makeText(ExampleActivity.this, s, Toast.LENGTH_SHORT).show();
textView.setText(s);
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(ExampleActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
}
});

列表类

public class LstCustomerOrderDetail {
@SerializedName("PtypeId")
@Expose
private String ptypeId;
@SerializedName("SubptypeId")
@Expose
private String subptypeId;
@SerializedName("productimgurl")
@Expose
private String productimgurl;
@SerializedName("subproductimgurl")
@Expose
private String subproductimgurl;
@SerializedName("Quantity")
@Expose
private String quantity;
@SerializedName("Rate")
@Expose
private String rate;
@SerializedName("Totalamount")
@Expose
private String totalamount;
@SerializedName("Paymentmode")
@Expose
private String paymentmode;
@SerializedName("Paymentstatus")
@Expose
private String paymentstatus;

如何将数据添加到所有 JSON custId...lstCustomerOrderDetails[]?我成功将数据提交到服务器,但数据未存储在数据库中。

我还添加了列表类,现在我的问题是如何向模型类和列表类添加数据?

最佳答案

看起来private String custIdprivate String distId应该是整数

关于java - 有没有办法实现以下 JSON pojo 类以及如何将数据传递到列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58892997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com