我正在尝试使用@Embedded 和 @Embeddable javax 注释来保持我的 Java 类更干净,但我希望生成的 JSON 被展平。
期望的行为:
[
{
"id": "6edbced5-2d27-4257-a140-2925291daaf6",
"name": "Online Maria DB",
"address": "Syble Forks",
"city": "Dallas",
"state": "Texas",
"country": "United States"
"phoneNumber": "(789) 740-5789",
"orgUserName": "online-maria"
}
]
实际行为:
[
{
"id": "6edbced5-2d27-4257-a140-2925291daaf6",
"name": "Online Maria DB",
"addressDetails": {
"address": "Syble Forks",
"city": "Dallas",
"state": "Texas",
"country": "United States"
},
"phoneNumber": "(789) 740-5789",
"orgUserName": "online-maria"
}
]
这可以使用这些注释吗?
到目前为止我所拥有的:
组织.java
@Embedded
private Address address;
地址.java
@Embeddable
public class Address {
...
}