2024-11-02 09:58:40
public static void main(String[] args) {
//初始化一个List
List<Province> list = new ArrayList<>();
//声明范型的实体1
Province c1 = new Province();
c1.setProvinceName("南京");
c1.setProvinceSort("1");
//声明范型的实体2
Province c2 = new Province();
c2.setProvinceName("北京");
c2.setProvinceSort("2");
//加入List中
list.add(c1);
list.add(c2);
//打印JSON格式的串
System.out.println(JSON.toJSON(list).toString());
}
[{"provinceName":"南京","provinceSort":"1"},{"provinceName":"北京","provinceSort":"2"}]
2024-11-02 06:06:39