杰克逊在换成json时改变私有变量的顺序?

时间:2016-07-14 21:53:26

标签: java json serialization jackson

我有以下POJO

public class Billing {

    private BigDecimal billingId;
    private BigDecimal asrId;
    private String billNm;
    private String sBillNm;
    private String acna;
    private String te;
    private String fusf;
    private String ebp;
    private String billStr;
    private String billFl;
    private String billRm;
    private String billCity;
    private String billState;
    private String billZip;
    private String billCon;
    private String billConTel;
    private String billConEmail;
    private String vta;
    private String vcvta;
    private String iwban;
    private String pnum;
    private String psd;

    private BasicAudit basicAudit = new BasicAudit();

    public BigDecimal getBillingId() {

        return billingId;
    }

    public void setBillingId(BigDecimal value) {

        this.billingId = value;
    }

    public BigDecimal getAsrId() {

        return asrId;
    }

    public void setAsrId(BigDecimal value) {

        this.asrId = value;
    }

    public String getBillNm() {

        return billNm;
    }

    public void setBillNm(String value) {

        this.billNm = value;
    }

    public String getSBillNm() {

        return sBillNm;
    }

    public void setSBillNm(String value) {

        this.sBillNm = value;
    }

    public String getAcna() {

        return acna;
    }

    public void setAcna(String value) {

        this.acna = value;
    }

    public String getTe() {

        return te;
    }

    public void setTe(String value) {

        this.te = value;
    }

    public String getFusf() {

        return fusf;
    }

    public void setFusf(String value) {

        this.fusf = value;
    }

    public String getEbp() {

        return ebp;
    }

    public void setEbp(String value) {

        this.ebp = value;
    }

    public String getBillStr() {

        return billStr;
    }

    public void setBillStr(String value) {

        this.billStr = value;
    }

    public String getBillFl() {

        return billFl;
    }

    public void setBillFl(String value) {

        this.billFl = value;
    }

    public String getBillRm() {

        return billRm;
    }

    public void setBillRm(String value) {

        this.billRm = value;
    }

    public String getBillCity() {

        return billCity;
    }

    public void setBillCity(String value) {

        this.billCity = value;
    }

    public String getBillState() {

        return billState;
    }

    public void setBillState(String value) {

        this.billState = value;
    }

    public String getBillZip() {

        return billZip;
    }

    public void setBillZip(String value) {

        this.billZip = value;
    }

    public String getBillCon() {

        return billCon;
    }

    public void setBillCon(String value) {

        this.billCon = value;
    }

    public String getBillconTel() {

        return billConTel;
    }

    public void setBillConTel(String value) {

        this.billConTel = value;
    }

    public String getBillConEmail() {

        return billConEmail;
    }

    public void setBillConEmail(String value) {

        this.billConEmail = value;
    }

    public String getVta() {

        return vta;
    }

    public void setVta(String value) {

        this.vta = value;
    }

    public String getVcvta() {

        return vcvta;
    }

    public void setVcvta(String value) {

        this.vcvta = value;
    }

    public String getIwban() {

        return iwban;
    }

    public void setIwban(String value) {

        this.iwban = value;
    }

    public String getPnum() {

        return pnum;
    }

    public void setPnum(String value) {

        this.pnum = value;
    }

    public String getPsd() {

        return psd;
    }

    public void setPsd(String value) {

        this.psd = value;
    }

    public BasicAudit getBasicAudit() {

        return basicAudit;
    }

    public Billing() {

        super();
    }
}

然后我运行以下代码以确保所有值都按顺序排列:

Billing billing = new Billing();
JsonNode node = mapper.convertValue(billing, JsonNode.class);
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(billing));

但我得到了这个:

{
  "billingId" : null,
  "asrId" : null,
  "billNm" : null,
  "acna" : null,
  "te" : null,
  "fusf" : null,
  "ebp" : null,
  "billStr" : null,
  "billFl" : null,
  "billRm" : null,
  "billCity" : null,
  "billState" : null,
  "billZip" : null,
  "billCon" : null,
  "billConEmail" : null,
  "vta" : null,
  "vcvta" : null,
  "iwban" : null,
  "pnum" : null,
  "psd" : null,
  "basicAudit" : {
    "createdDate" : null,
    "createdByUserId" : null,
    "updatedDate" : null,
    "updatedByUserId" : null
  },
  "sbillNm" : null,
  "billconTel" : null
}

为什么最后两个值出现故障? sBillNm应该在billNm之后,billConTel应该在billCon

之后

0 个答案:

没有答案