?? jsontest.java
字號:
package action;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
public class JsonTest {
public static void main(String[] args) {
JsonConfig cfg=new JsonConfig();
cfg.registerJsonValueProcessor(java.util.Date.class, new JsonValueProcessorImpl());
cfg.registerJsonValueProcessor(java.sql.Date.class, new JsonValueProcessorImpl());
// JSONObject json = JSONObject.fromObject(student,cfg);
// System.out.println(json);
List list=new ArrayList();
Student student=new Student();
student.setName("普羅米修斯");
student.setAge(12);
student.setBirthday(new Date());
list.add(student);
student=new Student();
student.setName("基礎");
student.setAge(22);
student.setBirthday(new Date());
list.add(student);
JSONArray array = JSONArray.fromObject(list,cfg);
System.out.println(array);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -