KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to use jackson json library for a generic method as follows: public MyRequest<T> tester() { TypeReference<MyWrapper<T>> typeRef = new TypeReference<MyWrapper<T>>(); MyWrapper<T> requestWrapper = (MyWrapper<T>) JsonConverter.fromJson(jsonRequest, typeRef); return requestWrapper.getRequest(); } public class MyWrapper<T> { private MyRequest<T> request; public MyRequest<T> getRequest() { return request; } public void setRequest(MyRequest<T> request) { this.request = request; } } public class MyRequest<T> { private List<T> myobjects; public void setMyObjects(List<T> ets) { this.myobjects = ets; } @NotNull @JsonIgnore public T getMyObject() { return myobjects.get(0); } } Now the problem is that when I call getMyObject() which is inside the request object Jackson returns the nested custom object as a LinkedHashMap. Is there any way in which I specify that T object needs to be returned? For example: if I sent object of type Customer then Customer should be returned from that List?
Tags (comma-separated)
Save Edits
Cancel