美好的一天,
请帮忙,我检查过Jackson JsonNode但我似乎找不到我要找的东西。
我需要知道如何将 JsonNode
获取为 LocalDate
// Example : I can get int value like :
ObjectMapper mapper = new ObjectMapper();
final JsonNode data =mapper.readTree(json);
Int myNumberInt = data.get ("ngNumberInt").asInt();
LocalDate
怎么样,如何从JsonNode
获取它?
在我看来,我希望有
LocalDate dateCreated = data.get ("ngDate").asLocalDate();
最佳答案
使用convertValue
方法
LocalDate date = mapper.convertValue(data.get("date"), LocalDate.class);
如上所述,必须在对象映射器上注册正确的 java8 日期时间反序列化器
关于java - Json节点获取asLocalDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47695681/