Jackson serialize generic collection <p>I want to use Jackson to serialize an object include a generic collection type. This is the interface:</p> <pre><code>public interface PagingAdapter &lt;Id extends Serializable, T extends Entity&lt;Id&gt;&gt; extends Serializable { public List&lt;T&gt; getItem(); public void setItem(List&lt;T&gt; items); public Boolean hasNextPage(); public Integer getTotalPage(); public Integer getPageSize(); public void setPageSize(int pageSize); public Long getTotalItem(); public void setTotalItem(Long totalItem); public void setCurrentPage(Integer currentPage); public Integer getCurrentPage(); public Class&lt;T&gt; getEntityType(); public void setEntityType(Class&lt;T&gt; entityType); } </code></pre> <p>and this is the implementation:</p> <pre><code>public class PagingAdapterImpl&lt;Id extends Serializable, T extends Entity&lt;Id&gt;&gt; implements PagingAdapter&lt;Id,T&gt; { private static Integer DEFAULT_PAGE_SIZE = 20; private Class&lt;T&gt; entityType; private List&lt;T&gt; items = null; private Integer pageSize = DEFAULT_PAGE_SIZE; private Integer currentPage = 0; private Long totalItem; public PagingAdapterImpl(List&lt;T&gt; items, int currentPage, int pageSize, long totalItem) { super(); this.items = items; this.pageSize = pageSize; this.currentPage = currentPage; this.totalItem = totalItem; } public PagingAdapterImpl(){ } @Override public Class&lt;T&gt; getEntityType() { return entityType; } @Override public void setEntityType(Class&lt;T&gt; entityType) { this.entityType = entityType; } @Override public List&lt;T&gt; getItem() { return items; } @Override public void setItem(List&lt;T&gt; items) { this.items = items; } @Override public Boolean hasNextPage() { return false; } @Override public Integer getTotalPage() { int rs = (int) (getTotalItem() % getPageSize() == 0 ? getTotalItem() / getPageSize() : getTotalItem() / getPageSize() + 1); return 0; } @Override public Integer getPageSize() { return this.pageSize; } @Override public Long getTotalItem() { return this.totalItem; } @Override public void setTotalItem(Long totalItem) { this.totalItem = totalItem; } @Override public void setCurrentPage(Integer currentPage) { this.currentPage = currentPage; } @Override public Integer getCurrentPage() { return currentPage; } @Override public void setPageSize(int pageSize) { this.pageSize = pageSize; } } </code></pre> <p>I'm using RestEasy with Jackson 1.9. Output of a rest method return instance of this object now like this:</p> <pre><code>{ "status": 0, "data": { "entityType": null, "pageSize": 1, "currentPage": 1, "totalItem": 1, "item": [], "totalPage": 0 } } </code></pre> <p>The "item" property cannot be serialized to a JSON array. How can I fix this problem?</p> <pre><code>public class PagingAdapterSerializer extends JsonSerializer&lt;PagingAdapter&lt;Long, Entity&lt;Long&gt;&gt;&gt; { @Override public void serialize(PagingAdapter&lt;Long, Entity&lt;Long&gt;&gt; value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeObjectField("item",value.getItem()); jgen.writeObjectField("totalItem",value.getTotalPage()); jgen.writeObjectField("pageSize",value.getPageSize()); jgen.writeObjectField("totalItem",value.getTotalItem()); jgen.writeObjectField("currentPage",value.getCurrentPage()); jgen.writeEndObject(); } </code></pre> <p>This is my custom serializer. But it doesn't works</p>