在Spring中反序列化LocalTime
时,我遇到了问题。
java.time.format.DateTimeParseException:Text'{“hour”:9,“minute”:0,“second”:0,“nano”:0}'无法在索引0处解析
这是我的代码:
@Override
public Office deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException,
JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
office.setOpenFrom(LocalTime.parse(node.get("openFrom").toString()));
return office;
}
我通过这种方法发送值:
@Test
public void readSingleBookmark() throws Exception {
RestTemplate tmp = new RestTemplate();
Office office = new Office();
office.setOpenFrom(LocalTime.parse("09:00"));
tmp.postForLocation("http://localhost:8080/register",office);
}