问题描述
我正在使用 spring boot2 来创建 rest api。我创建了一个rest api,我的实体类如下所示,
public class User {
@Id
@JsonIgnore
private int id;
@Column(name="name")
private String name;
@Column(name="age")
private int age;
@Embedded
private Address address;
....
}
我在 Address 类中有州、城市。当发送这个类作为回应时,我得到如下所示,
{"name":"Joseph","age":43,"address":{"city":"","state":""}}
但需要像平面一样,
{"name":"Joseph","city":"","state":""}
是否可以使用任何@Json.. 注释?我可以创建一个 DTO 类并使用 getter 和 setter 并分配它,但想使用更好的方法。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)