I am trying to deserialize some JSON which I got from the eBay API but I am getting the error: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
The JSON that is returned has many levels to it. e.g.
{"searchResult":[{"@count":"100","item":[{"itemId":["281492499859"],"title":["Panasonic Lumix TZ20 Digital Camera in Good Condition"],... etc
This is for a property called itemId in CompletedListing (class defined below)
I am calling this method with the line:
CompletedListingContainer listing = mapper.readValue(new File("C:\\resource\\jsonresult.txt"), CompletedListingContainer.class);`
Here are my classes.
CompletedListingContainer
public class CompletedListingContainer {
private ArrayList<CompletedListing> item;
private ArrayList<SearchResult> searchResult;
private List<String> paginationOutput;
@JsonIgnore
public List<String> getPaginationOutput() {
return paginationOutput;
}
public ArrayList<SearchResult> getSearchResult() {
return searchResult;
}
public ArrayList<CompletedListing> getItem() {
return item;
}
}
SearchResult
public class SearchResult {
@JsonProperty("@count")
private String count;
private ArrayList<CompletedListing> item;
@JsonIgnore
public String getCount() {
return count;
}
public ArrayList<CompletedListing> getItem() {
return item;
}
}
CompletedListing
public class CompletedListing {
@JsonProperty("itemId")
private String itemId;
private String title;
@JsonProperty("itemId")
public String getItemId() {
return itemId;
}
@JsonProperty("title")
public String getTitle() {
return title;
}
}
Any help would be greatly appreciated. Let me know if you need any more information.