Note that there are some explanatory texts on larger screens.

plurals
  1. POJackson deserialize generic with unknown property name
    primarykey
    data
    text
    <p>I have following <code>JSON</code>. And I am parsing it using <code> Jackson</code> Parser</p> <pre><code> { "code": 0, "response": { "pagination": { "page": 1, "limit": 20, "count": 5, "pageCount": 1 }, "random": [ .... ] } } </code></pre> <p>Now I have simple <code> POJO </code> classes created for various <code>random</code> object. I expect 3-4 different types of <code> random </code> object. So instead of creating different wrapper classes for different types of 'random' object I created a generic one</p> <p><b>EDITED CLASS:</b></p> <pre><code>public class PaginatedResponse&lt;E&gt; { private Pagination pagination; private List&lt;E&gt; responseList; public Pagination getPagination() { return pagination; } public void setPagination(Pagination pagination) { this.pagination = pagination; } public List&lt;E&gt; getResponseList() { return responseList; } public void setResponseList(List&lt;E&gt; responseList) { this.responseList = responseList; } } </code></pre> <p>Now For mapping it I used,</p> <pre><code> JsonNode tree = mapper.readTree(response); TypeReference&lt;PaginatedResponse&lt;LocationParent&gt;&gt; ref = new TypeReference&lt;PaginatedResponse&lt;LocationParent&gt;&gt;() { }; PaginatedResponse&lt;LocationParent&gt; resp = mapper.convertValue(tree.get("response"), ref); </code></pre> <p>But i am not able to map <code>responseList</code>. I get the <code> pagination </code> object but the <code>responseList</code> is always null. Now how to dynamically provide <code>property name</code> for <code>responseList</code>.</p> <p>Please help </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload