1
我有一個來自不具有默認構造函數的第三方API的java類之一的反序列化問題。爲了解決這個問題,我使用了JacksonMixIn,它工作正常罰款。但問題是,我有一個REST端點實現在澤西API接受上面提到的類之一作爲從客戶端到服務器端的方法參數。所以當反序列化它會引發下面的錯誤。如何在Jersey REST服務方法參數上使用jackson mixin
No suitable constructor found for type [simple type, class net.rcarz.jiraclient.Priority]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: [email protected]; line: 1, column: 454]...
受影響的類
public class TestCaseVO{
private Priority priority;
private User reporter;
}
public class Priority {
protected Priority(RestClient restclient, JSONObject json) {
super(restclient);
if (json != null)
deserialise(json);
}
}
這是用於客戶端通信到服務器
public class myDataObject{
private String userName;
private List<TestCaseVO> testCases;
//Getter and setters
}
澤西端點
對象@POST
@Path("/bug")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public TestCaseVO attachBugForTestCase(myDataObject myDataObject){
// when deserializing to MyDataObject it thorows above error
//Handle logic
}
客戶端代碼片斷
var myDataObject= {
"testCases": [$scope.bug.TestCaseVO],
"userName":userName}
angularJsMyService.Bug.attachBug({},myDataObject)
.$promise.then(function(data){
...
}
我的問題是,我怎麼能之前,傑克遜使用傑克遜的mixin上REST方法的參數反序列化them.Appreciate任何幫助。