mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-26 03:19:37 +08:00
Merge branch 'master' of https://github.com/alibaba/fastjson
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user