我在我的项目中使用了Spring boot Jackson dependency和lombok,作为响应,我得到了重复的字段,因为下划线
这是我的模型类:
@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor
@ToString
public class TcinDpciMapDTO {
@JsonProperty(value = "tcin")
private String tcin;
@JsonProperty(value = "dpci")
private String dpci;
@JsonProperty(value = "is_primary_tcin_in_dpci_relation")
private boolean is_primaryTcin = true;
}如果我在is_primaryTcin字段中使用下划线,我会得到下面带有重复字段的响应
{
"_primaryTcin": true,
"tcin": "12345",
"dpci": "12345",
"is_primary_tcin_in_dpci_relation": true
}如果我从字段isprimaryTcin中删除了下划线,那么我得到的响应是正确的
{
"tcin": "12345",
"dpci": "12345",
"is_primary_tcin_in_dpci_relation": true
}这是因为下划线吗?但是在变量名中最好使用下划线,对吗?
https://stackoverflow.com/questions/51313899
复制相似问题