使⽤ordinal指定字段的顺序
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43public class BasePackage { @JSONField(ordinal = 1) private int id; @JSONField(ordinal = 2) private int direction; @JSONField(ordinal = 3) private String type; @JSONField(ordinal = 5) private byte crc; @JSONField(ordinal = 4) private Object body; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getDirection() { return direction; } public void setDirection(int direction) { this.direction = direction; } public String getType() { return type; } public void setType(String type) { this.type = type; } public byte getCrc() { return crc; } public void setCrc(byte crc) { this.crc = crc; } public Object getBody() { return body; } public void setBody(Object body) { this.body = body; } }
赋值后转为json字符串后的结果举例:
复制代码
1
2{"id":2,"direction":0,"type":"input","body":{"no":21},"crc":204}#
字段的顺序即为ordinal标注的顺序
最后
以上就是紧张月饼最近收集整理的关于fastJson注解@JSONField指定字段的顺序的全部内容,更多相关fastJson注解@JSONField指定字段内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复