java ObjectMapper json 与对象的相互转换
public class Abc {
......
}
String path = "E:/apps/abc.json";
{
File file = new File(path);
ObjectMapper mapper = new ObjectMapper();
Abc abc= null;
try {
JsonNode jsonNode = mapper.readTree(file);
abc= mapper.treeToValue(jsonNode, Abc.class);
} catch (IOException e) {
log.error("解析{}异常,失败信息:{}", file.getName(), e.getMessage());
}
}