I am using Spring\'s MappingJacksonHttpMessageConverter to convert JSON message to object in my controller.
Check out this article describing how to use the features of the jackson objectMapper to accomplish this.
https://github.com/FasterXML/jackson-dataformat-xml/issues/21
For me adding the following solved this issue
jsonMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
As far as I see the incoming JSON doesn't contain any array. The question is: is "images" supposed to be separated or it contains a single image? Let's assume they are comma separated:
public class Product {
private String name;
private List<String> images;
@JsonProperty("images")
public String getImagesAsString() {
StringBuilder sb = new StringBuilder();
for (String img : images) {
if (sb.length() > 0) sb.append(',');
sb.append(img);
}
return sb.toString();
}
public void setImagesAsString(String img) {
this.images = Arrays.asList(img.split(","));
}
@JsonIgnore
public List<String> getImages() {
return images;
}
}