use of com.alibaba.fastjson.serializer.AfterFilter in project fastjson by alibaba.
the class AfterFilterTest2 method test_afterFilter.
public void test_afterFilter() throws Exception {
AfterFilter filter = new AfterFilter() {
@Override
public void writeAfter(Object object) {
this.writeKeyValue("id", 123);
}
};
Assert.assertEquals("{\"id\":123}", JSON.toJSONString(new VO(), filter));
}
use of com.alibaba.fastjson.serializer.AfterFilter in project fastjson by alibaba.
the class AfterFilterTest3 method test_afterFilter2.
public void test_afterFilter2() throws Exception {
AfterFilter filter = new AfterFilter() {
@Override
public void writeAfter(Object object) {
this.writeKeyValue("id", 123);
this.writeKeyValue("name", "wenshao");
}
};
Assert.assertEquals(JSON.toJSONString(new VO(), filter), "{\"value\":1001,\"id\":123,\"name\":\"wenshao\"}");
}
use of com.alibaba.fastjson.serializer.AfterFilter in project fastjson by alibaba.
the class AfterFilterTest3 method test_afterFilter.
public void test_afterFilter() throws Exception {
AfterFilter filter = new AfterFilter() {
@Override
public void writeAfter(Object object) {
this.writeKeyValue("id", 123);
}
};
Assert.assertEquals(JSON.toJSONString(new VO(), filter), "{\"value\":1001,\"id\":123}");
}
Aggregations