forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
26 lines (22 loc) · 765 Bytes
/
Copy pathMain.java
File metadata and controls
26 lines (22 loc) · 765 Bytes
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
package com.alibaba.json.bvtVO;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
public class Main {
public static void main(String[] args) {
Page<Bean> page = new Page<Bean>();
page.setCount(1);
List<Bean> items = new ArrayList<Bean>();
Bean item = new Bean();
item.setId(1);
item.setName("name");
item.setDesc("desc");
items.add(item);
page.setItems(items);
String json = JSON.toJSONString(page);
Page<Bean> jsonPage = JSON.parseObject(json, new TypeReference<Page<Bean>>() {
});
System.out.println(jsonPage.getItems().get(0).getName());
}
}