Note that there are some explanatory texts on larger screens.

plurals
  1. POdeserialize json array to java object using Jackson
    primarykey
    data
    text
    <p>given the following json:</p> <pre><code>{ "response": { "totalProcessingTime": "271.0", "resultSets": { "products": { "firstHit": "1", "lastHit": "10", "totalHits": "77", "hits": [ { "number": "1", "dmsubcategory": "TV, lyd og bilde", "collection": "tilbud", "title": "&lt;b&gt;TV&lt;/b&gt; Panasonic 47 TX-LU 7ET5Y" }, { "number": "2", "dmsubcategory": "TV, lyd og bilde", "collection": "tilbud", "title": "&lt;b&gt;TV&lt;/b&gt; Panasonic 47 TX-LU 7ET5Y" }, { "number": "3", "dmsubcategory": "TV, lyd og bilde", "collection": "tilbud", "title": "&lt;b&gt;TV&lt;/b&gt; Panasonic 47 TX-LU 7ET5Y" } ] } } } } </code></pre> <p>I'm using the following code to call jackson:</p> <pre><code>ObjectMapper mapper = new ObjectMapper(); SearchResult searchResult = mapper.readValue(new URL(jsonUrl + queryUrl), SearchResult.class); </code></pre> <p>I have ganerated POJOs for the whole hiearchy where the products class looks like:</p> <pre><code>public class Products { public List&lt;Hits&gt; hits; public String totalHits; @JsonAnySetter public void handleUnknown(String key, Object value) { // do something: put to a Map; log a warning, whatever } public List&lt;Hits&gt; getHits() { return hits; } public void setHits(List&lt;Hits&gt; hits) { this.hits = hits; } public String getTotalHits() { return totalHits; } public void setTotalHits(String totalHits) { this.totalHits = totalHits; } } </code></pre> <p>and the hits class:</p> <pre><code>public class Hits { public String number; public String title; public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } @JsonAnySetter public void handleUnknown(String key, Object value) { // do something: put to a Map; log a warning, whatever } } </code></pre> <p>All the other properties are mapped correct, but not the list containing hits. It's all empty. How can I map this to get it right? </p> <p>Thanks!</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.
 

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