RestTemplate

阅读更多

RestTemplate restTemplate = new RestTemplate();

ObjectMapper jsonToObjectMapper = new ObjectMapper();

ReceiveTO TOs = null;

String result = restTemplate.getForObject(URL, String.class);

String jsonString = result.replaceFirst("data", "{\"TOs \": [");

jsonString = jsonString.replaceAll("}", "},");

jsonString = jsonString.substring(0, jsonString.length() - 1);

jsonString = jsonString + "]}";

attributeTOs = jsonToObjectMapper.readValue(jsonString, ReceiveAttributeTO.class);

你可能感兴趣的:(restTemplate)