public void test_0() throws Exception {
Object[] array = { new ModelA(), new ModelB() };
SerializeConfig config = new SerializeConfig();
config.addFilter(ModelA.class, //
new PascalNameFilter());
config.addFilter(ModelB.class, //
new NameFilter() {
@Override
public String process(Object object, String name, Object value) {
return name;
}
});
String text2 = JSON.toJSONString(array, config);
Assert.assertEquals("[{\"Id\":1001},{\"id\":1002}]", text2);
String text = JSON.toJSONString(array);
Assert.assertEquals("[{\"id\":1001},{\"id\":1002}]", text);
}
NameFilterClassLevelTest.java 文件源码
java
阅读 41
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录