use of com.alibaba.fastjson.serializer.PropertyFilter in project fastjson by alibaba.
the class PropertyFilter_char method test_0.
public void test_0() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
};
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Assert.assertEquals("{}", text);
}
use of com.alibaba.fastjson.serializer.PropertyFilter in project fastjson by alibaba.
the class PropertyFilter_char method test_1.
public void test_1() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("id".equals(name)) {
Assert.assertTrue(value instanceof Character);
return true;
}
return false;
}
};
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Assert.assertEquals("{\"id\":\"0\"}", text);
}
use of com.alibaba.fastjson.serializer.PropertyFilter in project fastjson by alibaba.
the class PropertyFilter_char method test_4.
public void test_4() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return false;
}
return true;
}
};
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", (char) '3');
map.put("name", "chennp2008");
serializer.write(map);
String text = out.toString();
Assert.assertEquals("{\"id\":\"3\"}", text);
}
use of com.alibaba.fastjson.serializer.PropertyFilter in project fastjson by alibaba.
the class PropertyFilter_double method test_1.
public void test_1() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("id".equals(name)) {
Assert.assertTrue(value instanceof Double);
return true;
}
return false;
}
};
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Assert.assertEquals("{\"id\":0.0}", text);
}
use of com.alibaba.fastjson.serializer.PropertyFilter in project fastjson by alibaba.
the class PropertyFilter_double method test_0.
public void test_0() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
};
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Assert.assertEquals("{}", text);
}
Aggregations