问题描述
- jackson json 使用问题
- 有Department类
public class Department {
private Long id;
private String name;
private Department parDepartment;//上级部门//method set、get .......
}
有如下dept和dept1 2个对象,dept是dept1的上级部门
Department dept = new Department();
dept.setId(1L);
dept.setName(""宜通世纪"");Department dept1 = new Department();dept1.setId(2L);dept1.setName(""终端解决方案部"");dept1.setParDepartment(dept);
如何使用jackson的注解设置Department类,使得dept1转成json对象时是一下格式:
{""id"":2name"":""终端解决方案部""pId"":1}
时间: 2024-11-19 00:43:37