-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug where collection being cast to List when readingReferences, f…
…or issue #2302
- Loading branch information
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
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
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
27 changes: 27 additions & 0 deletions
27
core/src/test/java/com/alibaba/fastjson2/issues_2300/Issue2302.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,27 @@ | ||
package com.alibaba.fastjson2.issues_2300; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author 张治保 | ||
* @since 2024/3/8 | ||
*/ | ||
public class Issue2302 { | ||
@Test | ||
void test() { | ||
TestA a = new TestA(); | ||
a.areaIds.add(1000); | ||
String jsonStr = JSON.toJSONString(a); | ||
TestA newTest = JSON.parseObject(jsonStr, TestA.class); | ||
Assertions.assertEquals(newTest.areaIds, a.areaIds); | ||
} | ||
|
||
private static class TestA { | ||
public Set<Integer> areaIds = new HashSet<>(); | ||
} | ||
} |