forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmoryTest.java
More file actions
executable file
·68 lines (46 loc) · 1.52 KB
/
Copy pathArmoryTest.java
File metadata and controls
executable file
·68 lines (46 loc) · 1.52 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.alibaba.json.bvt;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class ArmoryTest extends TestCase {
public void test_0() throws Exception {
List<Object> message = new ArrayList<Object>();
MessageHead head = new MessageHead();
MessageBody body = new MessageBody();
body.getItems().add(new Item());
message.add(head);
message.add(body);
String text = JSON.toJSONString(message, SerializerFeature.SortField, SerializerFeature.UseSingleQuotes);
Assert.assertEquals("[{},{'items':[{'id':0,'name':'xx'}]}]", text);
}
public static class Item {
private int id;
private String name = "xx";
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public static class MessageHead {
}
public static class MessageBody {
private List<Object> items = new ArrayList<Object>();
public List<Object> getItems() {
return items;
}
public void setItems(List<Object> items) {
this.items = items;
}
}
}