-
Notifications
You must be signed in to change notification settings - Fork 541
Closed
Labels
Milestone
Description
dubbo 3.2.x
jdk 8
spring cloud alibaba 2021.0.6
fastjson2 2.0.48
代码如下,结果是courseId 属性值丢失:
@Data
public class RmsFinishCourseDTO implements Serializable {
private static final long serialVersionUID = -2350411810429763923L;
@RedisKey
private String courseId;
@RedisKey
private String userId;
/**
* 当前学习进度
*/
private String studyRate;
/**
* 资源id
*/
private String resourceId;
private String providerCorpCode;
private String userAgent;
private String sourceId;
}
RmsFinishCourseDTO course =new RmsFinishCourseDTO();
course.setCourseId("6bad799a1c894893bedade17215244a1");
course.setUserId("4b99d48f87f84868a59aa3b3ce82fd56");
byte[] bytes = JSONB.toBytes(course, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.FieldBased,
JSONWriter.Feature.ErrorOnNoneSerializable, JSONWriter.Feature.ReferenceDetection,
JSONWriter.Feature.WriteNulls, JSONWriter.Feature.NotWriteDefaultValue,
JSONWriter.Feature.NotWriteHashMapArrayListClassName, JSONWriter.Feature.WriteNameAsSymbol);
RmsFinishCourseDTO result =
JSONB.parseObject(bytes, RmsFinishCourseDTO.class, JSONReader.Feature.UseDefaultConstructorAsPossible,
JSONReader.Feature.ErrorOnNoneSerializable, JSONReader.Feature.IgnoreAutoTypeNotMatch,
JSONReader.Feature.UseNativeObject, JSONReader.Feature.FieldBased);
System.out.println(result);