resttemplate getForObject map responsetype

后端 未结 6 1743
囚心锁ツ
囚心锁ツ 2021-02-06 23:58

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

6条回答
  •  -上瘾入骨i
    2021-02-07 00:21

    I think you can achieve what you're aiming for simply using the RestTemplate and specifying a JsonNode as the response type.

        ResponseEntity response = 
             restTemplate.exchange(url, HttpMethod.GET, entity, JsonNode.class);
    
        JsonNode map = response.getBody();
    
        String someValue = map.get("someValue").asText();
    

提交回复
热议问题