-
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.
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 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
22 changes: 22 additions & 0 deletions
22
core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2851.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,22 @@ | ||
package com.alibaba.fastjson2.issues_2800; | ||
|
||
import com.alibaba.fastjson2.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2851 { | ||
@Test | ||
public void test() { | ||
List<String> list = Arrays.asList("").subList(0, 1); | ||
byte[] bytes = JSONB.toBytes(list, JSONWriter.Feature.WriteClassName); | ||
JSONReader.AutoTypeBeforeHandler autoTypeFilter = JSONReader.autoTypeFilter("java.util.AbstractList"); | ||
JSONReader.Context context = JSONFactory.createReadContext(); | ||
context.config(autoTypeFilter); | ||
List<String> parsed = (List<String>) JSONB.parse(bytes, context); | ||
assertEquals(list.get(0), parsed.get(0)); | ||
} | ||
} |