forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bug_for_issue_937.java
54 lines (42 loc) · 1.16 KB
/
Bug_for_issue_937.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Created by wuwen on 2016/12/7.
*/
public class Bug_for_issue_937 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{outPara:{name:\"user\"}}";
Out<Info> out = returnOut(json, Info.class);
Assert.assertEquals("user", out.getOutPara().getName());
}
public static <T> Out<T> returnOut(String jsonStr, Class<T> c2) {
return JSON.parseObject(jsonStr, new TypeReference<Out<T>>(c2) {
});
}
public static class Out<T> {
private T outPara;
public void setOutPara(T t) {
outPara = t;
}
public T getOutPara() {
return outPara;
}
public Out() {
}
public Out(T t) {
setOutPara(t);
}
}
public static class Info {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}