fastjson设置生成的json属性的顺序
目标JSON顺序:
{"url":"http://img.xxx.com/test/f62d3d591c4346d6a4a572b78783504b/TATA.webp","w":110,"h":110,"s":800}
1.url
2.w
3.h
4.s
如果使用默认情况生成,则顺序为:
w,h,s,url
在fastJson中,可以使用@JSONField来指定属性顺序(需要1.1.42以上版本)
public class OSSImage { @JSONField(ordinal = 1) private String url; @JSONField(ordinal = 2) private Integer w; @JSONField(ordinal = 3) private Integer h; @JSONField(ordinal = 4) private Integer s; //get set }
参考链接:http://www.oschina.net/question/2336560_229478?sort=default&p=1#answers