-
Notifications
You must be signed in to change notification settings - Fork 541
Closed
Description
问题描述
保持POJO中定义的字段顺序不生效
重现步骤
- 仅仅设置alphabetic = false不能保持Bean的字段顺序。
- 同时设置JJSONWriter.Feature.FieldBased才起作用。
import java.math.BigDecimal;
import java.util.Date;
import com.alibaba.fastjson2.annotation.JSONType;
import lombok.Data;
@Data
@JSONType(alphabetic = false)
public class TobeDelivery {
private String ProjectNO;
private String OrderNO;
private String OrderType;
private String PN;
private Integer Qty;
private String Description;
private String CustomerCode;
private String CustomerName;
private String Currency;
private BigDecimal NetPrice;
private BigDecimal USD;
private Float Rate;
private Date OrderDate;
private Date RequestDate;
private Date PlanedDate;
}
JSON.config(JSONWriter.Feature.FieldBased);
期待的正确结果
建议
设置@jsontype(alphabetic = false) 或者JSON.config(JSONWriter.Feature.FieldBased), 两者任意一个都能保持字段定义的顺序。