use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class Issue763 method test_0.
public void test_0() throws Exception {
Map<String, Object> reqDto = new HashMap<String, Object>();
reqDto.put("name", "aaaa");
reqDto.put("age", 50);
reqDto.put("address", "深圳南山");
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
filter.getExcludes().add("name");
// SerializeConfig.getGlobalInstance().addFilter(Map.class, filter);
SerializeConfig config = new SerializeConfig();
config.addFilter(HashMap.class, filter);
System.out.println(JSON.toJSONString(reqDto, config));
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_name_a1.
public void test_name_a1() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter("name");
Assert.assertEquals("{\"name\":\"sandzhangtoo\"}", JSON.toJSONString(a, filter));
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_map.
public void test_map() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(VO.class, "name");
String text = JSON.toJSONString(map, filter);
Assert.assertTrue("{\"id\":123,\"name\":\"sandzhangtoo\"}".equals(text) || "{\"name\":\"sandzhangtoo\",\"id\":123}".equals(text));
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_id_0.
public void test_id_0() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter("id");
Assert.assertEquals("{\"id\":123}", JSON.toJSONString(vo, filter));
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_name_a.
public void test_name_a() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(VO.class, "name");
Assert.assertEquals(VO.class, filter.getClazz());
Assert.assertEquals(1, filter.getIncludes().size());
Assert.assertTrue(filter.apply(null, null, null));
String text = JSON.toJSONString(a, filter);
Assert.assertTrue("{\"id\":123,\"name\":\"sandzhangtoo\"}".equals(text) || "{\"name\":\"sandzhangtoo\",\"id\":123}".equals(text));
}
Aggregations