import java.io.Serializable;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
//通过Serializable的toString方法,将类转变为json字符串
public class AwardPara implements Serializable {
private String merchantId;
private String sn;
private String timestamp;
private Body body;//内部类
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
//注意内部类的set方法
public Body getBody() {
如何写一个嵌套实体类,赋值,转化为JSON格式的字符串
最新推荐文章于 2024-07-02 04:56:32 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
1、下面是实体类的写法