我使用 spring 2.0.5 Release 作为父级。我是春天的新手。我正在使用此 API https://www.metaweather.com/api/location/2487956/尝试使用对象映射器显示它,但我遇到了 RestTemplate 问题。
public void read() throws IOException {
RestTemplate rest = new RestTemplate();
ResponseEntity<String> response = rest.getForEntity("https://www.metaweather.com/api/location/2487956", String.class);
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(response.getBody());
JsonNode name = root.path("weather_state_name");
System.out.println(response.getBody());
}
喵喔喔
相关分类