-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
Issue3810.java
40 lines (33 loc) · 1.14 KB
/
Issue3810.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.alibaba.json.bvt.issue_3800;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.ParameterizedTypeImpl;
import junit.framework.TestCase;
import lombok.Data;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* https://github.com/alibaba/fastjson/issues/3810
*
* @author hnyyghk
* @date 2021/06/30 18:40
*/
public class Issue3810 extends TestCase {
@Data
static class TestA<T> {
T a;
}
@Data
static class TestB {
String b;
}
private final static String json = "{\"a\":[{\"b\":\"b\"}]}";
public void test_for_issue() throws Exception {
ParameterizedTypeImpl inner = new ParameterizedTypeImpl(new Type[]{TestB.class}, List.class, List.class);
ParameterizedTypeImpl outer = new ParameterizedTypeImpl(new Type[]{inner}, TestA.class, TestA.class);
JSONObject jo = JSONObject.parseObject(json);
TestA<List<?>> ret = jo.toJavaObject(outer);
assertEquals(ArrayList.class.getName(), ret.getA().getClass().getName());
assertEquals(TestB.class.getName(), ret.getA().get(0).getClass().getName());
}
}