高铁 edited this page Aug 11, 2017 · 3 revisions


Support Version

1.2.10 and later



public class SerializeConfig {
	public void addFilter(Class<?> clazz, SerializeFilter filter);


public class ClassNameFilterTest extends TestCase {
    public void test_filter() throws Exception {
        NameFilter upcaseNameFilter = new NameFilter() {
            public String process(Object object, String name, Object value) {
                return name.toUpperCase();
        SerializeConfig.getGlobalInstance() //
                       .addFilter(A.class, upcaseNameFilter);
        Assert.assertEquals("{\"ID\":0}", JSON.toJSONString(new A()));
        Assert.assertEquals("{\"id\":0}", JSON.toJSONString(new B()));

    public static class A {
        public int id;

    public static class B {
        public int id;
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.