我具有如下所示的JSON模式,
angular
.module('employeesApp')
.controller('employeeController', function ($scope, employeeService) {
});
我有以下模型课
angular
.module('employeesApp')
.service('employeeService', function () {
});
当我尝试使用{
"prty_id": "hgh",
"customer_id": "ghjghjghj"
}
PARTY主体作为方法参数进行反序列化时,我正在获取POJO类字段的空值。
public class PARTY {
@JsonAlias({"prty_id", "prtyId"})
String prtyId;
@JsonAlias({"customer_id", "customerId"})
String customerId;
......
}
答案 0 :(得分:0)
您需要在您的课堂上写下吸气剂,以便杰克逊反骗局能够奏效。此外,最好在定义中使用CamelCase:
public class Party {
@JsonAlias({"prty_id", "prtyId"})
String prtyId;
@JsonAlias({"customer_id", "customerId"})
String customerId;
public String getPrtyId() {
return prtyId;
}
public String getCustomerId() {
return customerId;
}
}
编辑:添加控制器:
@PostMapping("/test")
public Party test(@RequestBody Party body) {
return body;
}
答案 1 :(得分:0)
我建议同时使用@JsonProperty
和@JsonAlias
。试试吧。
@JsonProperty
@JsonAlias(xxx, xxx)
private String xxx;
就是这样。乍一看,代码应该可以工作。