This commit is contained in:
wenshao
2013-05-23 19:19:49 +08:00
4 changed files with 122 additions and 49 deletions
@@ -0,0 +1,19 @@
package com.alibaba.json.bvt.bug;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Bug_for_wsky extends TestCase {
public void test_writeMapNull() throws Exception {
JSON.parseObject(JSON.toJSONString(new MethodReturn(), SerializerFeature.WriteMapNullValue), MethodReturn.class);
}
public static class MethodReturn {
public Object ReturnValue;
public Throwable Exception;
}
}
@@ -0,0 +1,43 @@
package com.alibaba.json.bvt.serializer;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
public class JSONFieldTest extends TestCase {
public void test_jsonField() throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("xx");
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"id\":123}", text);
}
public static class VO {
private int id;
@JSONField(serialize=false)
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}