@Table(name="send_json_message")
@JsonPropertyOrder({"touser","msgType"})
public class JSONMessage implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6191639680513644936L;
@JsonIgnore
private Integer id;
private String touser;
@JsonProperty(value="msgtype")
private String msgType;
@JsonIgnore
private Long createTime;
private Message message;
public String getTouser() {
return touser;
}
public void setTouser(String touser) {
this.touser = touser;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Embedded
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
/**
*
*/
public JSONMessage() {
super();
}
/**
@param touser
@param msgType
@param createTime
@param message
*/
public JSONMessage(String touser, String msgType, Long createTime,
Message message) {
super();
this.touser = touser;
this.msgType = msgType;
this.createTime = createTime;
this.message = message;
}
}
如上,我添加了@JsonPropertyOrder({"touser","msgType"}) ,可是输出的字符串的顺序还是不是我想要的,message、msgtype、touser,貌似一直是字典顺序,我关闭了字典排序也不管用,郁闷啊,这个解决呢?
MapperFeature#SORT_PROPERTIES_ALPHABETICALLY 默认是 false
objectMapper.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。