Because there's no way to specify the type of the List to return, I get back a List of Map instead. It'd be nice if there was a way to specify the List's generic type so that I can get back a List<Foo> and not have to extract Foo objects from Map objects.
1 votes, 4 watchers
The text was updated successfully, but these errors were encountered:
The problem I see is that Lists would only work for certain media types, such as JSON, and perhaps XML. But even with these two media types I can see a lot of problems, as they both represent a tree structure (and not a sequence). JSON (or Jackson, rather) has some nice workarounds for this as shown above, but JAXB (for instance) does not, AFAIK.
We could create some arbitrary way to convert these tree structures into a list, but I think that will cause more bugs than it will solve.
If I am understanding correctly what is discussed here, you may consider using ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) instead. See this javadoc for more details, and also #17745 for same kind of need applied to the request body (planned for 4.3).