1、使用@Data 的注解后,对象转换时字段少的情况下会转换错误。
2、转为JSON串时,对字段值为空的字段保留:
JSON.toJSONString(student,SerializerFeature.WriteMapNullValue);
3、转换结果是list<Student>的时候,直接转换list后list里面是JSONObject对象,需要循环再一次转换才行。
List<Student> stuList = new ArrayList();
List tempList = JSON.parseObject(str,List.Class);
for(Object strObj:tempList){
Student stu = JSON.parseObject(strObj.toString(),Student.Class);
stuList.add(stu);
}
return stuList;
记录一下。