mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-28 22:04:04 +08:00
bug fixed for generic types
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
public class Bug_for_huangchun extends TestCase {
|
||||
public void test_serialize_url() throws Exception {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("info", "<a href=\"http://www.baidu.com\"> 问题链接 </a> ");
|
||||
String text = JSON.toJSONString(json);
|
||||
System.out.println(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.alibaba.json.bvt.bug;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
public class Bug_for_jinghui70 extends TestCase {
|
||||
|
||||
public static abstract class IdObject<I> {
|
||||
|
||||
private I id;
|
||||
|
||||
public I getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(I id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Child extends IdObject<Long> {
|
||||
|
||||
}
|
||||
|
||||
public void test_generic() throws Exception {
|
||||
String str = "{\"id\":0}";
|
||||
|
||||
Child child = JSON.parseObject(str, Child.class);
|
||||
Assert.assertEquals(Long.class, child.getId().getClass());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user