JSON解析
<!-- json解析依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>RELEASE</version>
</dependency>
public static void main(String[] args) {
Student student1 = new Student("踏歌长行1号",100);
Student student2 = new Student("踏歌长行2号",900);
Student student3 = new Student("踏歌长行3号",80);
List<Student> students = new ArrayList<Student>();
students.add(student1);
students.add(student2);
students.add(student3);
System.out.println("********JAVA对象列表转json字符串**********");
String str1 = JSON.toJSONString(students);
System.out.println(str1);
System.out.println("********JAVA对象转json字符串**********");
String str2 = JSON.toJSONString(student1);
System.out.println(str2);
System.out.println("********json字符串转JAVA对象列表**********");
List<Student> studentsTurn = JSON.parseArray(str1, Student.class);
studentsTurn.forEach(System.out::println);
System.out.println("********json字符串转JAVA对象**********");
Student student4 = JSON.parseObject(str2,Student.class);
System.out.println(student4);
}