I have an REST service already working which returns the sample JSON below:
{
"_embedded" : {
"artist" : [ {
"name" : "+44",
"genre" : "Rock",
"country" : "USA",
"id" : 469,
"_links" : {
"self" : {
"href" : <ADDRESS>
},
"albumList" : {
"href" : <ADDRESS>
}
}
} ]
}
}
I'm trying to consume this resource using RestTemplate like the example below
public static void main(String args[]) {
RestTemplate restTemplate = new RestTemplate();
Artist[] artistList = restTemplate.getForObject("http://localhost:8080/artists/search/findByName?name=+44", Artist[].class);
for (Artist a : artistList)
System.out.println(a.toString());
}
}
When the debbuger hits the getForObject line, it get this error:
Exception in thread "main" org.springframework.http.converter.HttpMessageNotReadableException:
Could not read JSON: Can not deserialize instance of br.com.lagranzotto.itunes.frontend.entity.Artist[] out of START_OBJECT token
I've searched the internet extensively for about a week with no success in finding the cause of this exception.