Update 02/05/2018 (about 4 years later)...I tested this again as people have been upvoting my question/answer and Sotirios Delimanolis is correct that I should not h
RestTemplate has a method named exchange that takes an instance of ParameterizedTypeReference as parameter.
To make a GET request that returns a java.util.Map
, just create an instance of an anonym class that inherits from ParameterizedTypeReference.
ParameterizedTypeReference> responseType =
new ParameterizedTypeReference>() {};
You can then invoke the exchange method:
RequestEntity request = RequestEntity.get(URI("http://example.com/foo"))
.accept(MediaType.APPLICATION_JSON).build()
Map jsonDictionary = restTemplate.exchange(request, responseType)