依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.2</version>
</dependency>
转Jackson方法:
Student student=new Student();
student.setId(1);
student.setName("sss");
System.out.println(new ObjectMapper().writeValueAsString(student));
//{"id":1,"name":"sss","gender":null,"major":null}