我收到错误com.fasterxml.jackson.databind.exc.MismatchedInputException:由于输入结束,没有内容要映射 在[来源:(String)“”;行:1,列:0]
我有一个像这样的json响应
{
"value": [
{
"createdDateTime": "2019-05-16T03:29:40Z",
"description": "",
"id": "b!7hKJzLqQQkajNbvHNFsz2Ala4mlEFR9Aq-xoMIepKEhs0_tqRKx8T4Q3nq0WrgJv",
}
{
"createdDateTime": "2019-04-16T03:29:40Z",
"description": "",
"id": "differentID",
}
]
}
我正尝试使用每个对象创建一个“驱动器”(来自Microsoft Graph API的Microsoft库)对象
private final ObjectMapper objectMapper = new ObjectMapper();
ResponseEntity<String> response = restTemplate.exchange(getUrl, HttpMethod.GET, request, String.class);
logger.info("response code:" + response.getStatusCodeValue());
JsonNode jsonBody = objectMapper.readTree(response.getBody());
// the root drives are in the value key of the response as an array
jsonBody = jsonBody.path("value");
System.out.println(jsonBody);
for (JsonNode node : jsonBody) {
Drive drive = objectMapper.readValue(node.asText(), Drive.class);
rootDrives.add(drive);
}