【发布时间】:2021-06-17 11:47:14
【问题描述】:
我正在尝试使用 jackson 将字符串转换为 json。
我使用了ObjectMapper().readValue() 并反序列化为一个 DragDropJsonDto 类
qList.getHeader() is like this "<p>{
"RC" : ["N" , "Raj" , "USA"],
"LC" : [
"Enter Country Name :" ,
"Enter State Name :",
"Enter City Name :" ]
}</p>"
公共类 DragDropJsonDto {
private List<String> RC;
private List<String> LC;
public List<String> getRC() {
return RC;
}
public void setRC(List<String> RC) {
this.RC = RC;
}
public List<String> getLC() {
return LC;
}
public void setLC(List<String> LC) {
this.LC = LC;
}
}
DragDropJsonDto dragDropJson = new ObjectMapper().readValue(qList.getHeader(), DragDropJsonDto.class);
我无法转换成 json 出现异常
Error Unrecognized field "RC" (class com.visataar.lt.web.dto.DragDropJsonDto), not marked as ignorable (2 known properties: "rc", "lc"])
【问题讨论】: