0
我在Spring中使用FastJsonHttpMessageConverter发现的该问题。我跟踪了一下代码,发现最后调用的是JSON.parseObject(String text, Class
public class ParseTest {
public static void main(String[] args) {
String str = "{\"taskId\":\"7d590240bc394753835a38244378df0f\",\"condition\":{\"taskPurposeCode\":null,\"data\":{\"name\":\"全领域评价模型\",\"id\":553,\"type\":\"FULL\",\"version\":\"20191225175002\"},\"fieldCode\":\"13ecf353f2faf550b1dbb1e868828e71\",\"creditType\":3,\"fieldId\":\"5ee812fe9dbf4929b29a5cfc9cf13ff8\"}}";
TaskDTO dto = JSON.parseObject(str, TaskDTO.class);
System.out.println(dto.getCondition());
}
}
class TaskDTO implements Serializable {
private String taskId;
private String condition;
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
}
运行后,丢失了"taskPurposeCode":null。
除了修改我的JavaBean外,还有什么方法避免这个问题吗?