use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class Bug_for_issue_285 method test_for_issue.
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.v1 = new V1();
vo.v1.v2 = new V2();
vo.v1.v2.v3 = new V3();
vo.v1.v2.v3.v4 = new V4();
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
filter.setMaxLevel(2);
String text = JSON.toJSONString(vo, filter);
Assert.assertEquals("{\"v1\":{\"v2\":{}}}", text);
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class Issue184 method test_for_issue.
public void test_for_issue() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
VO vo = new VO();
vo.setDate(new Date());
String text = JSON.toJSONString(vo, filter);
System.out.println(text);
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_all.
public void test_all() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(VO.class);
String text = JSON.toJSONString(vo, 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_exclude_id_map.
public void test_exclude_id_map() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(VO.class);
filter.getExcludes().add("id");
Assert.assertEquals("{\"name\":\"sandzhangtoo\"}", JSON.toJSONString(vo, filter));
}
use of com.alibaba.fastjson.serializer.SimplePropertyPreFilter in project fastjson by alibaba.
the class SimplePropertyPreFilterTest method test_id.
public void test_id() throws Exception {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter(VO.class, "id");
Assert.assertEquals("{\"id\":123}", JSON.toJSONString(vo, filter));
}
Aggregations