-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ba62ad
commit 04688d0
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...gen-test/src/test/java/com/alibaba/fastjson2/internal/processor/issues/Issue2411Bean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.alibaba.fastjson2.internal.processor.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONReader; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import com.alibaba.fastjson2.annotation.JSONCompiled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2411Bean { | ||
static JSONWriter.Feature[] writerFeatures = { | ||
JSONWriter.Feature.FieldBased, | ||
JSONWriter.Feature.WriteNameAsSymbol | ||
}; | ||
static JSONReader.Feature[] readerFeatures = { | ||
JSONReader.Feature.UseDefaultConstructorAsPossible, | ||
JSONReader.Feature.ErrorOnNoneSerializable, JSONReader.Feature.IgnoreAutoTypeNotMatch, | ||
JSONReader.Feature.UseNativeObject, JSONReader.Feature.FieldBased | ||
}; | ||
|
||
@Test | ||
public void test() { | ||
Bean course = new Bean(); | ||
course.courseId = "6bad799a1c894893bedade17215244a1"; | ||
course.userId = "4b99d48f87f84868a59aa3b3ce82fd56"; | ||
|
||
String json = JSON.toJSONString(course, writerFeatures); | ||
|
||
Bean result = JSON.parseObject(json, Bean.class, readerFeatures); | ||
|
||
assertEquals(course.userId, result.userId); | ||
assertEquals(course.courseId, result.courseId); | ||
} | ||
|
||
@JSONCompiled | ||
public static class Bean { | ||
public String courseId; | ||
public String userId; | ||
public String studyRate; | ||
public String resourceId; | ||
public String providerCorpCode; | ||
public String userAgent; | ||
public String sourceId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters