Search in sources :

Example 1 with SimplePropertyPreFilter

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);
}
Also used : SimplePropertyPreFilter(com.alibaba.fastjson.serializer.SimplePropertyPreFilter)

Example 2 with SimplePropertyPreFilter

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);
}
Also used : SimplePropertyPreFilter(com.alibaba.fastjson.serializer.SimplePropertyPreFilter) Date(java.util.Date)

Example 3 with SimplePropertyPreFilter

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));
}
Also used : SimplePropertyPreFilter(com.alibaba.fastjson.serializer.SimplePropertyPreFilter)

Example 4 with SimplePropertyPreFilter

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));
}
Also used : SimplePropertyPreFilter(com.alibaba.fastjson.serializer.SimplePropertyPreFilter)

Example 5 with SimplePropertyPreFilter

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));
}
Also used : SimplePropertyPreFilter(com.alibaba.fastjson.serializer.SimplePropertyPreFilter)

Aggregations

SimplePropertyPreFilter (com.alibaba.fastjson.serializer.SimplePropertyPreFilter)20 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)3 Date (java.util.Date)1 HashMap (java.util.HashMap)1